ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2024-08-26 05:06:07
Exec Total Coverage
Lines: 9085 12001 75.7%
Functions: 354 407 87.0%
Branches: 7238 12752 56.8%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 #include "zc/combos.h"
26 extern particle_list particles;
27
28 extern ZModule zcm;
29 extern HeroClass Hero;
30 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
31
32 int32_t repaircharge=0;
33 bool adjustmagic=false;
34 bool learnslash=false;
35 int32_t wallm_load_clk=0;
36 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
37 int32_t vhead=0;
38 int32_t guycarryingitem=0;
39
40 char *guy_string[eMAXGUYS];
41
42 void never_return(int32_t index);
43 void playLevelMusic();
44
45 // If an enemy is this far out of the playing field, just remove it.
46 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
47 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 1111957 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 1111957 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 1111690 times.
1111957 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111690 times.
1111690 if (c < 0)
57 c -= val / 2;
58 1111690 else c += (val/2);
59 1111690 }
60 1111957 c -= c % val;
61 1111957 coord = c;
62 1111957 }
63
64 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
65 {
66 return
67 (
68 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
69 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
70 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
71 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
72 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
73 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
74 );
75 }
76
77 namespace
78 {
79 int32_t trapConstantHorizontalID;
80 int32_t trapConstantVerticalID;
81 int32_t trapLOSHorizontalID;
82 int32_t trapLOSVerticalID;
83 int32_t trapLOS4WayID;
84
85 int32_t cornerTrapID;
86 int32_t centerTrapID;
87
88 int32_t rockID;
89 int32_t zoraID;
90 int32_t statueID;
91 }
92
93 372 void identifyCFEnemies()
94 {
95 372 trapConstantHorizontalID=-1;
96 372 trapConstantVerticalID=-1;
97 372 trapLOSHorizontalID=-1;
98 372 trapLOSVerticalID=-1;
99 372 trapLOS4WayID=-1;
100 372 cornerTrapID=-1;
101 372 centerTrapID=-1;
102 372 rockID=-1;
103 372 zoraID=-1;
104 372 statueID=-1;
105
106
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 372 times.
190836 for(int32_t i=0; i<eMAXGUYS; i++)
107 {
108
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 190097 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
190464 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
109 367 trapLOSHorizontalID=i;
110
4/4
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 190086 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
111 372 trapLOSVerticalID=i;
112
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
113 372 trapLOS4WayID=i;
114
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
115 372 trapConstantHorizontalID=i;
116
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
117 372 trapConstantVerticalID=i;
118
119
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
120 372 cornerTrapID=i;
121
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
122 372 centerTrapID=i;
123
124
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags&guy_rock) && rockID==-1)
125 372 rockID=i;
126
4/4
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 190073 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 370 times.
190464 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
127 370 zoraID=i;
128
129
4/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 190033 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags & guy_fire) && statueID==-1)
130 372 statueID=i;
131 190464 }
132 372 }
133
134 32 int32_t random_layer_enemy()
135 {
136 32 int32_t cnt=count_layer_enemies();
137
138
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
139 {
140 return eNONE;
141 }
142
143 32 int32_t ret=zc_oldrand()%cnt;
144 32 cnt=0;
145
146
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
147 {
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tmpscr->layermap[i]!=0)
149 {
150 32 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
151
152
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
153 {
154
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
155 {
156
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
157 {
158 32 return layerscreen->enemy[j];
159 }
160
161 108 ++cnt;
162 108 }
163 108 }
164 }
165 }
166
167 return eNONE;
168 32 }
169
170 49 int32_t count_layer_enemies()
171 {
172 49 int32_t cnt=0;
173
174
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
175 {
176
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if(tmpscr->layermap[i]!=0)
177 {
178 79 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
179
180
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
181 {
182
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
183 {
184 420 ++cnt;
185 420 }
186 790 }
187 79 }
188 294 }
189
190 49 return cnt;
191 }
192
193 211789 int32_t hero_on_wall()
194 {
195 211789 zfix lx = Hero.getX();
196 211789 zfix ly = Hero.getY();
197
198
199
200
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=192)
201 {
202
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
203
204
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==128) return down+1;
205 180473 }
206
207
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=112)
208 {
209
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
210
211
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==208) return right+1;
212 172303 }
213
214 210948 return 0;
215 211789 }
216
217 765533 bool tooclose(int32_t x,int32_t y,int32_t d)
218 {
219
2/2
✓ Branch 0 taken 567824 times.
✓ Branch 1 taken 197709 times.
765533 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
220 }
221
222 3989892 bool enemy::overpit(enemy *e)
223 {
224 // This function (and shadow_overpit) has been broken since it was written, and only
225 // checked the same diagonal of the hitbox, over and over again. The bug is because both
226 // loops used the same variable name.
227 // Checking literally every pixel seems like overkill, so for now let's continue to
228 // do the single diagonal but just once. That's why the outer loop is commented out.
229
230 // for ( int32_t q = 0; q < hxsz; ++q )
231 {
232
2/2
✓ Branch 0 taken 36952798 times.
✓ Branch 1 taken 3970690 times.
40923488 for ( int32_t q = 0; q < hit_height; ++q )
233 {
234 //check every pixel of the hitbox
235
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 36933596 times.
36952798 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
236 {
237 //if the hitbox is over a pit, we can't land
238 19202 return true;
239 }
240 36933596 }
241 }
242 3970690 return false;
243 3989892 }
244
245 12250275 bool enemy::shadow_overpit(enemy *e)
246 {
247 // for ( int32_t q = 0; q < hxsz; ++q )
248 {
249
2/2
✓ Branch 0 taken 176046221 times.
✓ Branch 1 taken 12223814 times.
188270035 for ( int32_t q = 0; q < hit_height; ++q )
250 {
251 //check every pixel of the hitbox
252
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 176019760 times.
176046221 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
253 {
254 //if the hitbox is over a pit, we can't land
255 26461 return true;
256 }
257 176019760 }
258 }
259 12223814 return false;
260 12250275 }
261
262 // Returns true iff a combo type or flag precludes enemy movement.
263 7430873 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
264 {
265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7430873 times.
7430873 if(moveflags & move_ignore_blockflags) return false;
266 7430873 int32_t c = COMBOTYPE(dx,dy);
267
4/4
✓ Branch 0 taken 4890323 times.
✓ Branch 1 taken 2540550 times.
✓ Branch 2 taken 1398325 times.
✓ Branch 3 taken 1142225 times.
9971423 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
268
3/6
✓ Branch 0 taken 2522226 times.
✓ Branch 1 taken 4908647 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2522226 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7430873 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
269
5/6
✓ Branch 0 taken 2581772 times.
✓ Branch 1 taken 4849101 times.
✓ Branch 2 taken 2579895 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2579895 times.
✗ Branch 5 not taken.
14862510 return c==cPIT || c==cPITB || c==cPITC ||
270
4/6
✓ Branch 0 taken 2579895 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2579895 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2431147 times.
✓ Branch 5 taken 148748 times.
2579895 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
271 // Block enemies type and block enemies flags
272
2/2
✓ Branch 0 taken 2574619 times.
✓ Branch 1 taken 2425871 times.
148748 combo_class_buf[c].block_enemies&1 ||
273
4/4
✓ Branch 0 taken 2571949 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2571702 times.
✓ Branch 3 taken 247 times.
2574619 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
274
4/4
✓ Branch 0 taken 2570884 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2570818 times.
✓ Branch 3 taken 66 times.
2571702 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
275 // Check for ladder-only combos which aren't dried water
276
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2560192 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5141341 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
277 // Check for drownable water
278
4/4
✓ Branch 0 taken 572182 times.
✓ Branch 1 taken 1998341 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 570282 times.
2570523 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
279 2584413 }
280
281 // Returns true iff enemy is floating and blocked by a combo type or flag.
282 8647530 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
283 {
284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8647530 times.
8647530 if(moveflags & move_ignore_blockflags) return false;
285
4/4
✓ Branch 0 taken 6549648 times.
✓ Branch 1 taken 2097882 times.
✓ Branch 2 taken 1749423 times.
✓ Branch 3 taken 348459 times.
10745412 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
286
3/4
✓ Branch 0 taken 6564155 times.
✓ Branch 1 taken 2083375 times.
✓ Branch 2 taken 2083375 times.
✗ Branch 3 not taken.
10730905 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
287
2/2
✓ Branch 0 taken 1200911 times.
✓ Branch 1 taken 7446619 times.
16094149 return ((special==spw_floater)&&
288
2/2
✓ Branch 0 taken 7436494 times.
✓ Branch 1 taken 10125 times.
7446619 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
289
2/2
✓ Branch 0 taken 7436375 times.
✓ Branch 1 taken 119 times.
7436494 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
290
2/2
✓ Branch 0 taken 7436204 times.
✓ Branch 1 taken 171 times.
7436375 (MAPFLAG(dx,dy)==mfNOENEMY)||
291
2/2
✓ Branch 0 taken 7435949 times.
✓ Branch 1 taken 255 times.
7436204 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
292
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6193420 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14867894 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
293
2/2
✓ Branch 0 taken 6183831 times.
✓ Branch 1 taken 1248114 times.
7431945 (pit_blocks && ispitfall(dx,dy))));
294 8647530 }
295 // Returns true iff a combo type or flag precludes enemy movement.
296 268958 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
297 {
298 268958 int32_t c = COMBOTYPE(dx,dy);
299 268958 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
300
2/2
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 235501 times.
268958 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
301
5/6
✓ Branch 0 taken 268938 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 268821 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 268821 times.
✗ Branch 5 not taken.
1014723 return c==cPIT || c==cPITB || c==cPITC ||
302
4/6
✓ Branch 0 taken 268821 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268821 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239045 times.
✓ Branch 5 taken 29776 times.
268821 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
303 // Block enemies type and block enemies flags
304
2/2
✓ Branch 0 taken 268248 times.
✓ Branch 1 taken 238472 times.
29776 combo_class_buf[c].block_enemies&1 ||
305
4/4
✓ Branch 0 taken 267922 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 267891 times.
✓ Branch 3 taken 31 times.
268248 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
306
4/4
✓ Branch 0 taken 264391 times.
✓ Branch 1 taken 3500 times.
✓ Branch 2 taken 264116 times.
✓ Branch 3 taken 275 times.
267891 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
307 // Check for ladder-only combos which aren't dried water
308
4/4
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 263074 times.
✓ Branch 2 taken 1003 times.
✓ Branch 3 taken 39 times.
528193 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
309 // Check for drownable water
310
4/4
✓ Branch 0 taken 42399 times.
✓ Branch 1 taken 221678 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 18395 times.
264077 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
311 }
312
313 // Returns true iff enemy is floating and blocked by a combo type or flag.
314 122271 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
315 {
316
2/2
✓ Branch 0 taken 119948 times.
✓ Branch 1 taken 2323 times.
122271 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
317 122271 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122271 times.
244542 return ((special==spw_floater)&&
319
2/2
✓ Branch 0 taken 122174 times.
✓ Branch 1 taken 97 times.
122271 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
320
2/2
✓ Branch 0 taken 122169 times.
✓ Branch 1 taken 5 times.
122174 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
321
2/2
✓ Branch 0 taken 122160 times.
✓ Branch 1 taken 9 times.
122169 (MAPFLAG(dx,dy)==mfNOENEMY)||
322
2/2
✓ Branch 0 taken 122131 times.
✓ Branch 1 taken 29 times.
122160 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
323
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 119810 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
244012 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
324
2/2
✓ Branch 0 taken 119810 times.
✓ Branch 1 taken 2071 times.
121881 (pit_blocks && ispitfall(dx,dy))));
325 }
326
327
4/8
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114522 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114522 times.
✗ Branch 7 not taken.
229044 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
328 114522 {
329
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 x=X;
330
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 y=Y;
331 114522 id=Id;
332 114522 clk=Clk;
333
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 floor_y=y;
334 114522 ceiling=false;
335 114522 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
336 114522 grumble = movestatus = posframe = timer = ox = oy = 0;
337
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114522 times.
✗ Branch 5 not taken.
114522 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
338 114522 did_armos=true;
339 114522 script_spawned=false;
340
341 114522 d = guysbuf + (id & 0xFFF);
342 114522 hp = d->hp;
343 114522 starting_hp = hp;
344 // cs = d->cset;
345 //d variables
346
347 114522 flags=d->flags;
348 114522 flags=d->flags;
349 114522 s_tile=d->s_tile; //secondary (additional) tile(s)
350 114522 family=d->family;
351 114522 dcset=d->cset;
352 114522 cs=dcset;
353
2/2
✓ Branch 0 taken 88397 times.
✓ Branch 1 taken 26125 times.
114522 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
354 114522 dp=d->dp;
355 114522 wdp=d->wdp;
356 114522 wpn=d->weapon;
357 114522 wpnsprite = d-> wpnsprite; //2.6 -Z
358 114522 rate=d->rate;
359 114522 hrate=d->hrate;
360
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 dstep=d->step;
361 114522 homing=d->homing;
362 114522 dmisc1=d->attributes[0];
363 114522 dmisc2=d->attributes[1];
364 114522 dmisc3=d->attributes[2];
365 114522 dmisc4=d->attributes[3];
366 114522 dmisc5=d->attributes[4];
367 114522 dmisc6=d->attributes[5];
368 114522 dmisc7=d->attributes[6];
369 114522 dmisc8=d->attributes[7];
370 114522 dmisc9=d->attributes[8];
371 114522 dmisc10=d->attributes[9];
372 114522 dmisc11=d->attributes[10];
373 114522 dmisc12=d->attributes[11];
374 114522 dmisc13=d->attributes[12];
375 114522 dmisc14=d->attributes[13];
376 114522 dmisc15=d->attributes[14];
377 114522 dmisc16=d->attributes[15];
378 114522 dmisc17=d->attributes[16];
379 114522 dmisc18=d->attributes[17];
380 114522 dmisc19=d->attributes[18];
381 114522 dmisc20=d->attributes[19];
382 114522 dmisc21=d->attributes[20];
383 114522 dmisc22=d->attributes[21];
384 114522 dmisc23=d->attributes[22];
385 114522 dmisc24=d->attributes[23];
386 114522 dmisc25=d->attributes[24];
387 114522 dmisc26=d->attributes[25];
388 114522 dmisc27=d->attributes[26];
389 114522 dmisc28=d->attributes[27];
390 114522 dmisc29=d->attributes[28];
391 114522 dmisc30=d->attributes[29];
392 114522 dmisc31=d->attributes[30];
393 114522 dmisc32=d->attributes[31];
394
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 110446 times.
114522 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
395 {
396 110446 dmisc31 = dmisc32;
397 110446 dmisc32 = 0;
398 110446 }
399 114522 spr_shadow=d->spr_shadow;
400 114522 spr_death=d->spr_death;
401 114522 spr_spawn=d->spr_spawn;
402
403
2/2
✓ Branch 0 taken 4695402 times.
✓ Branch 1 taken 114522 times.
4809924 for(int32_t i=0; i<edefLAST255; i++)
404 4695402 defense[i]=d->defense[i];
405
406 114522 bgsfx=d->bgsfx;
407 114522 hitsfx=d->hitsfx;
408 114522 deadsfx=d->deadsfx;
409 114522 bosspal=d->bosspal;
410 114522 parent_script_UID = 0;
411
412 114522 frozentile = d->frozentile;
413
414 114522 frozencset = d->frozencset;
415 114522 frozenclock = 0;
416
2/2
✓ Branch 0 taken 1145220 times.
✓ Branch 1 taken 114522 times.
1259742 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
417
418
2/2
✓ Branch 0 taken 1946874 times.
✓ Branch 1 taken 114522 times.
2061396 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
419 //firesfx = 0; //t.b.a -Z
420 114522 isCore = true; //t.b.a
421 114522 parentCore = 0; //t.b.a
422
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
423
424 114522 firesfx = d->firesfx;
425
2/2
✓ Branch 0 taken 3664704 times.
✓ Branch 1 taken 114522 times.
3779226 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
426
2/2
✓ Branch 0 taken 3664704 times.
✓ Branch 1 taken 114522 times.
3779226 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
427
428 114522 script = d->script;
429 114522 weaponscript = d->weaponscript;
430
431
2/2
✓ Branch 0 taken 916176 times.
✓ Branch 1 taken 114522 times.
1030698 for ( int32_t q = 0; q < 8; q++ )
432 {
433 916176 initD[q] = d->initD[q];
434 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
435 916176 weap_initiald[q] = d->weap_initiald[q];
436 916176 }
437
2/2
✓ Branch 0 taken 229044 times.
✓ Branch 1 taken 114522 times.
343566 for ( int32_t q = 0; q < 2; q++ )
438 {
439 229044 initA[q] = d->initA[q];
440 229044 weap_initiala[q] = d->weap_initiala[q];
441 229044 }
442
443 114522 stickclk = 0;
444 114522 submerged = false;
445 114522 didScriptThisFrame = false;
446 114522 ffcactivated = 0;
447 114522 hitdir = -1;
448 114522 dialogue_str = 0; //set by spawn flags.
449 114522 editorflags = d->editorflags; //set by Enemy Editor
450 //Set the drawing flag for this sprite.
451
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
452
453
454
2/2
✓ Branch 0 taken 8858 times.
✓ Branch 1 taken 105664 times.
114522 if(bosspal>-1)
455 {
456
1/2
✓ Branch 0 taken 8858 times.
✗ Branch 1 not taken.
8858 loadpalset(csBOSS,pSprite(bosspal));
457 8858 }
458
459
2/2
✓ Branch 0 taken 49811 times.
✓ Branch 1 taken 64711 times.
114522 if(bgsfx>-1)
460 {
461
1/2
✓ Branch 0 taken 49811 times.
✗ Branch 1 not taken.
49811 cont_sfx(bgsfx);
462 49811 }
463
464
2/2
✓ Branch 0 taken 88397 times.
✓ Branch 1 taken 26125 times.
114522 if(get_qr(qr_NEWENEMYTILES))
465 {
466 88397 o_tile=d->e_tile;
467 88397 frate = d->e_frate;
468 88397 }
469 else
470 {
471 26125 o_tile=d->tile;
472 26125 frate = d->frate;
473 }
474
475 114522 tile=0; //init to 0 here, but set it later.
476
477 114522 scripttile = -1;
478 114522 scriptflip = -1;
479 114522 do_animation = true;
480 114522 immortal = false;
481 114522 noSlide = false;
482 114522 deathexstate = -1;
483
484 114522 hashero=false;
485
486 // If they forgot the invisibility flag, here's another failsafe:
487
4/4
✓ Branch 0 taken 5791 times.
✓ Branch 1 taken 108731 times.
✓ Branch 2 taken 5697 times.
✓ Branch 3 taken 94 times.
114522 if(o_tile==0 && family!=eeSPINTILE)
488
1/2
✓ Branch 0 taken 5697 times.
✗ Branch 1 not taken.
5697 flags |= guy_invisible;
489
490 // step = d->step/100.0;
491 // To preserve the odd step values for Keese & Gleeok heads. -L
492
5/8
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12145 times.
✓ Branch 5 taken 102377 times.
✓ Branch 6 taken 12145 times.
✗ Branch 7 not taken.
114522 if(dstep==62.0) dstep+=0.5;
493
5/8
✓ Branch 0 taken 102377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102377 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 101678 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102377 else if(dstep==89) dstep-=1/9;
494
495
5/10
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114522 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114522 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114522 times.
✗ Branch 9 not taken.
114522 step = zslongToFix(dstep*100);
496
497
498 114522 item_set = d->item_set;
499 114522 grumble = d->grumble;
500
501
2/2
✓ Branch 0 taken 89927 times.
✓ Branch 1 taken 24595 times.
114522 if(frate == 0)
502 24595 frate = 256;
503
504 114522 leader = itemguy = dying = scored = false;
505 114522 canfreeze = count_enemy = true;
506
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 mainguy = !(flags & guy_doesnt_count);
507
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 dir = zc_oldrand()&3;
508
509 //2.6 Enemy Editor Hit and TIle Sizes
510
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114513 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
511 // al_trace("Enemy txsz:%i\n", txsz);
512
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114513 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
513
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
514
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
516
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
517
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
518 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
521 {
522 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
523 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
524 }
525
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
527
528 114522 SIZEflags = d->SIZEflags;
529
530
8/10
✓ Branch 0 taken 114273 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114156 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
114522 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
531 1 wpn = 0;
532
533 //tile should never be 0 after init --Z (failsafe)
534
4/6
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107959 times.
✓ Branch 5 taken 6563 times.
114522 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
535
536 //Moveflags; for gravity and pit interaction
537 114522 moveflags = d->moveflags;
538
3/4
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17660 times.
✓ Branch 3 taken 96862 times.
114522 if(!can_pitfall(false))
539 {
540 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
541
2/4
✓ Branch 0 taken 17660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17660 times.
✗ Branch 3 not taken.
17660 moveflags &= ~move_can_pitfall;
542
2/4
✓ Branch 0 taken 17660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17660 times.
✗ Branch 3 not taken.
17660 moveflags &= ~move_can_waterdrown;
543 17660 }
544
545 114522 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
546 114522 }
547
548 598 int32_t enemy::getScriptUID() { return script_UID; }
549 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
550 114290 enemy::~enemy()
551 114290 {
552
2/4
✓ Branch 0 taken 114290 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114290 times.
✗ Branch 3 not taken.
114290 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
553
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114277 times.
114290 if(hashero)
554 {
555
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
556 13 hashero=false;
557 13 }
558 114290 }
559
560 bool enemy::is_move_paused()
561 {
562 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
563 }
564
565 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
566 {
567 7024 int32_t yg = (special==spw_floater)?8:0;
568 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
569 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
570
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
571 input_x = dx;
572
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
573 input_y = dy;
574
575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
576
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
577
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
578 return true;
579
580
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
581 {
582 if(ispitfall(dx,dy))
583 return true;
584 }
585
586 7024 bool flying = false;
587 7024 bool cansolid = false;
588
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(moveflags & move_ignore_solidity)
589 cansolid = true;
590
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
591 {
592 case spw_clipbottomright:
593 if(dy>=128 || dx>=208) return true;
594 break;
595 case spw_clipright:
596 break; //if(input_x>=208) return true; break;
597
598 case spw_wizzrobe: // fall through
599 case spw_floater: // Special case for fliers and wizzrobes - hack!
600 {
601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon() && !(moveflags & move_ignore_screenedge))
602 {
603 if(dy < 32-yg || dy >= 144) return true;
604 if(dx < 32 || dx >= 224) return true;
605 }
606
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
607 return true;
608 317 cansolid = true;
609 317 flying = true;
610 }
611 317 }
612
613 7024 dx &= ~7;
614 7024 dy &= ~7;
615
616
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
617
618
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
619 return !(moveflags & move_ignore_screenedge);
620 //_walkflag code
621 mapscr *s1, *s2;
622 7024 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
623 7024 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
624
625 7024 int32_t cpos=(dx>>4)+(dy&0xF0);
626
3/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1038 times.
✓ Branch 3 taken 5986 times.
7024 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
627 7024 newcombo const& c = combobuf[ci];
628 7024 newcombo const& c1 = combobuf[ci1];
629 7024 newcombo const& c2 = combobuf[ci2];
630
631 7024 int32_t b=1;
632
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
633
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
634
635 #define iwtr(cmb, x, y, shallow) \
636 (shallow \
637 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
638 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
639 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
640 7024 bool wtr = iwtr(ci, dx, dy, false);
641
2/2
✓ Branch 0 taken 3551 times.
✓ Branch 1 taken 3473 times.
7024 bool shwtr = iwtr(ci, dx, dy, true);
642 7024 bool pit = ispitfall(dx,dy);
643
644
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
645
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
646 7024 bool needwtr = (moveflags & move_only_waterwalk);
647 7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
648 7024 bool needpit = (moveflags & move_only_pitwalk);
649
650
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
651 {
652 6707 int32_t cwalkflag = c.walk & 0xF;
653
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
655 {
656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
657 {
658 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
659 {
660 int efflag = (c1.walk & 0xF0)>>4;
661 int newsolid = (c1.walk & 0xF);
662 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
663 }
664 else cwalkflag &= c1.walk;
665 }
666 6707 else cwalkflag |= c1.walk & 0xF;
667 6707 }
668
2/2
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 721 times.
6707 if (s2)
669 {
670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if (c2.type == cBRIDGE)
671 {
672 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
673 {
674 int efflag = (c2.walk & 0xF0)>>4;
675 int newsolid = (c2.walk & 0xF);
676 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
677 }
678 else cwalkflag &= c2.walk;
679 }
680 721 else cwalkflag |= c2.walk & 0xF;
681 721 }
682
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
683 239 return true;
684 6468 }
685
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
686 {
687 bool ret = true;
688 if (needwtr && wtr) ret = false;
689 else if (needshwtr && shwtr) ret = false;
690 else if (needpit && pit) ret = false;
691 return ret;
692 }
693
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
694 return true;
695
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
696 return true;
697
698 6785 return false;
699 7024 }
700
701 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
702 {
703
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
704 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
705 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
706
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
707 {
708 if((moveflags & move_obeys_grav) && isSideViewGravity())
709 return false;
710 }
711
712
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
713
714
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
715 {
716
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
717 {
718
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
719 770 int mx = (bx+dx).getFloor();
720
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
721 {
722
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
723 return false;
724 2976 }
725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
726 return false;
727
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
728 return false;
729 770 }
730 else
731 {
732 341 int mx = (rx+dx).getCeil();
733 341 int lx = mx-hit_width+1;
734
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
735 {
736
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
737 1 return false;
738 2141 }
739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
740 return false;
741
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
742 return false;
743 }
744 1110 }
745
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
746 {
747
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
748 {
749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
750 315 int my = (by+dy).getFloor();
751
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
752 {
753
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
754 238 return false;
755 154 }
756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
757 return false;
758
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
759 return false;
760 77 }
761 else
762 {
763 109 int my = (ry+dy).getCeil();
764 109 int ly = my-hit_height+1;
765
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
766 {
767
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
768 return false;
769 218 }
770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
771 return false;
772
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
773 return false;
774 }
775 186 }
776 else //! Untested, and currently unused.
777 {
778 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
779 }
780 1296 return true;
781 1535 }
782
783 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
784 {
785 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
786 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
787
788 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
789
790 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
791 return false;
792 for(zfix ty = 0; by+ty < ry; ty += 8)
793 {
794 for(zfix tx = 0; bx+tx < rx; tx += 8)
795 {
796 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
797 return false;
798 }
799 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
800 return false;
801 }
802 for(zfix tx = 0; bx+tx < rx; tx += 8)
803 {
804 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
805 return false;
806 }
807 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
808 return false;
809 return true;
810 }
811
812 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
813 {
814 auto oxsz = hit_width, oysz = hit_height;
815 if(nwid > -1) hit_width = nwid;
816 if(nhei > -1) hit_height = nhei;
817 bool ret = scr_canplace(dx,dy,special,kb);
818 hit_width = oxsz; hit_height = oysz;
819 return ret;
820 }
821
822 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
823 {
824 1311 bool ret = true;
825
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
826 dy = 0;
827 1311 const int scl = 2;
828
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
829 {
830
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
831 {
832 260 int32_t tdx = dx.sign() * scl;
833
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
834 260 dx -= tdx;
835 else
836 {
837 if(earlyret) return false;
838 dx = tdx;
839 ret = false;
840 }
841 260 }
842 else
843 {
844 34 int32_t tdy = dy.sign() * scl;
845
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
846 27 dy -= tdy;
847 else
848 {
849
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
850 7 dy = tdy;
851 7 ret = false;
852 }
853 }
854 }
855
856
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
857 {
858
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
859 1110 x += dx;
860 else
861 {
862
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
863 ret = false;
864 int xsign = dx.sign();
865 while(scr_canmove(xsign, 0, special, kb, ign_sv))
866 {
867 x += xsign;
868 dx -= xsign;
869 }
870 if(dx)
871 {
872 dx.doDecBound(0,-9999, 0,9999);
873 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
874 if(scr_canmove(val, 0, special, kb, ign_sv))
875 {
876 retval = val;
877 return BSEARCH_CONTINUE_AWAY0;
878 }
879 else return BSEARCH_CONTINUE_TOWARD0;
880 });
881 x += dx;
882 }
883 }
884 1110 }
885
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
886 {
887
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
888 186 y += dy;
889 else
890 {
891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
892 14 ret = false;
893 14 int ysign = dy.sign();
894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
895 {
896 y += ysign;
897 dy -= ysign;
898 }
899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
900 {
901 14 dy.doDecBound(0,-9999, 0,9999);
902
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
904 {
905 retval = val;
906 return BSEARCH_CONTINUE_AWAY0;
907 }
908 210 else return BSEARCH_CONTINUE_TOWARD0;
909 210 });
910 14 y += dy;
911 14 }
912 }
913 200 }
914 1310 return ret;
915 1311 }
916
917 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
918 {
919
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
920
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
921 {
922 case up:
923 return movexy(0, -px, special, kb, false, earlyret);
924 case down:
925 16 return movexy(0, px, special, kb, false, earlyret);
926 case left:
927 479 return movexy(-px, 0, special, kb, false, earlyret);
928 case right:
929 259 return movexy(px, 0, special, kb, false, earlyret);
930 case r_up:
931 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
932 case r_down:
933 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
934 case l_up:
935 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
936 case l_down:
937 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
938 }
939 return false;
940 754 }
941
942 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
943 {
944 double v = degrees.getFloat() * PI / 180.0;
945 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
946 return movexy(dx, dy, special, kb, false, earlyret);
947 }
948
949 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
950 {
951 zfix tx = x, ty = y;
952 bool ret = movexy(dx, dy, special, kb, false, true);
953 x = tx;
954 y = ty;
955 return ret;
956 }
957 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
958 {
959 754 zfix tx = x, ty = y;
960 754 bool ret = moveDir(dir, px, special, kb, true);
961 754 x = tx;
962 754 y = ty;
963 754 return ret;
964 }
965 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
966 {
967 zfix tx = x, ty = y;
968 bool ret = moveAtAngle(degrees, px, special, kb, true);
969 x = tx;
970 y = ty;
971 return ret;
972 }
973
974 // Handle pitfalls
975 37826557 bool enemy::do_falling(int32_t index)
976 {
977
2/2
✓ Branch 0 taken 37824259 times.
✓ Branch 1 taken 2298 times.
37826557 if(fallclk > 0)
978 {
979
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2265 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 20 times.
2298 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
980
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 22 times.
2298 if(!--fallclk)
981 {
982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
983 ++fallclk; //force another frame of falling.... forever.
984
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
985 {
986
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
987 never_return(index);
988
989
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
990 kill_em_all();
991
992 //leave_item(); //Don't drop items in pits!
993 11 stop_bgsfx(index);
994 11 return true;
995 }
996 else
997 {
998 11 try_death(true); //Force death
999 11 ++fallclk; //force another frame of falling
1000 }
1001 11 }
1002
1003 2287 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1004 2287 cs = spr.csets & 0xF;
1005
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t fr = spr.frames ? spr.frames : 1;
1006
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t spd = spr.speed ? spr.speed : 1;
1007 2287 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1008
2/2
✓ Branch 0 taken 1101 times.
✓ Branch 1 taken 1186 times.
2287 tile = spr.tile + zc_min(animclk / spd, fr-1);
1009 2287 }
1010 37826546 return false;
1011 37826557 }
1012
1013 // Handle drowning in water
1014 37824259 bool enemy::do_drowning(int32_t index)
1015 {
1016
1/2
✓ Branch 0 taken 37824259 times.
✗ Branch 1 not taken.
37824259 if(drownclk > 0)
1017 {
1018 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1019 //!TODO: Drown SFX
1020 if(!--drownclk)
1021 {
1022 if(immortal) //Keep alive forever
1023 ++drownclk; //force another frame of falling.... forever.
1024 else if(dying) //Give 1 frame for script revival
1025 {
1026 if(flags&guy_never_return)
1027 never_return(index);
1028
1029 if(leader)
1030 kill_em_all();
1031
1032 //leave_item(); //Don't drop items in pits!
1033 stop_bgsfx(index);
1034 return true;
1035 }
1036 else
1037 {
1038 try_death(true); //Force death
1039 ++drownclk; //force another frame of falling
1040 }
1041 }
1042
1043 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1044 {
1045 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1046 cs = spr.csets & 0xF;
1047 int32_t fr = spr.frames ? spr.frames : 1;
1048 int32_t spd = spr.speed ? spr.speed : 1;
1049 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1050 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1051 }
1052 else
1053 {
1054 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1055 cs = spr.csets & 0xF;
1056 int32_t fr = spr.frames ? spr.frames : 1;
1057 int32_t spd = spr.speed ? spr.speed : 1;
1058 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1059 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1060 }
1061 }
1062 37824259 return false;
1063 37824259 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38488847 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38487018 times.
38488847 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 763084 times.
✓ Branch 1 taken 37723934 times.
38487018 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 763083 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
763084 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 763084 --clk2;
1083
1084
4/4
✓ Branch 0 taken 723458 times.
✓ Branch 1 taken 39626 times.
✓ Branch 2 taken 38640 times.
✓ Branch 3 taken 3195 times.
763084 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41835 times.
✓ Branch 1 taken 681623 times.
723458 && hp>-1000) // not killed by ringleader
1086 38640 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 719703 times.
✓ Branch 1 taken 43381 times.
763084 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42677 times.
✓ Branch 1 taken 704 times.
43381 if(flags&guy_never_return)
1091 704 never_return(index);
1092
1093
2/2
✓ Branch 0 taken 43310 times.
✓ Branch 1 taken 71 times.
43381 if(leader)
1094 71 kill_em_all();
1095
1096 43381 leave_item();
1097 43381 }
1098
1099 763084 stop_bgsfx(index);
1100 763084 return (clk2==0);
1101 }
1102
1103 37723934 return false;
1104 38488847 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 37826813 bool enemy::animate(int32_t index)
1110 {
1111
2/2
✓ Branch 0 taken 1683478 times.
✓ Branch 1 taken 36143335 times.
37826813 if(sclk <= 0) hitdir = -1;
1112
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37826557 times.
37826813 if(switch_hooked)
1113 {
1114
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1115 {
1116 //Run its script
1117 if (!didScriptThisFrame)
1118 {
1119 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1120 {
1121 return 0; //Avoid NULLPO if this object deleted itself
1122 }
1123 }
1124 }
1125 256 return false;
1126 }
1127
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37826546 times.
37826557 if(do_falling(index)) return true;
1128
2/2
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 37824259 times.
37826546 else if(fallclk)
1129 {
1130 //clks
1131
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 676 times.
2287 if(hclk>0)
1132 676 --hclk;
1133
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(stunclk>0)
1134 --stunclk;
1135
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if ( frozenclock > 0 )
1136 --frozenclock;
1137
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(hashero)
1138 {
1139 Hero.setX(x);
1140 Hero.setY(y);
1141 Hero.fallCombo = fallCombo;
1142 Hero.fallclk = fallclk;
1143 hashero = false; //Let Hero go if falling
1144 }
1145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2287 times.
2287 if (!didScriptThisFrame)
1146 {
1147 2287 run_script(MODE_NORMAL);
1148 2287 }
1149 2287 return false;
1150 }
1151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37824259 times.
37824259 if(do_drowning(index)) return true;
1152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37824259 times.
37824259 else if(drownclk)
1153 {
1154 //clks
1155 if(hclk>0)
1156 --hclk;
1157 if(stunclk>0)
1158 --stunclk;
1159 if ( frozenclock > 0 )
1160 --frozenclock;
1161 if(hashero)
1162 {
1163 Hero.setX(x);
1164 Hero.setY(y);
1165 Hero.drownclk = drownclk;
1166 hashero = false; //Let Hero go if falling
1167 }
1168 if (!didScriptThisFrame)
1169 {
1170 run_script(MODE_NORMAL);
1171 }
1172 return false;
1173 }
1174 37824259 int32_t nx = real_x(x);
1175 37824259 int32_t ny = real_y(y);
1176
1177
4/4
✓ Branch 0 taken 27356867 times.
✓ Branch 1 taken 10467392 times.
✓ Branch 2 taken 5644011 times.
✓ Branch 3 taken 21712856 times.
37824259 if(ox!=nx || oy!=ny)
1178 {
1179 16111403 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1180 16111403 }
1181
1182 37824259 ox = nx;
1183 37824259 oy = ny;
1184
1185 // Maybe they fell off the bottom in sideview, or were moved by a script.
1186
1187 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1188
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37822430 times.
37824259 if ( immortal )
1189 {
1190 //skip, as it can go out of bounds, from immortality
1191 1829 }
1192
2/6
✓ Branch 0 taken 37822430 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37822430 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37822430 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1193 {
1194 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1195 }
1196
9/10
✓ Branch 0 taken 37426337 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 37821425 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 37791401 times.
✓ Branch 5 taken 30024 times.
✓ Branch 6 taken 37791401 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 37791350 times.
37822430 else if ( (OUTOFBOUNDS) )
1197 {
1198 31080 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1199 31080 }
1200 //fall down
1201
6/6
✓ Branch 0 taken 27135246 times.
✓ Branch 1 taken 10689013 times.
✓ Branch 2 taken 10421486 times.
✓ Branch 3 taken 27402773 times.
✓ Branch 4 taken 506382 times.
✓ Branch 5 taken 9915104 times.
37824259 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1202 {
1203
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 9611530 times.
9915104 if(isSideViewGravity())
1204 {
1205
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1206 {
1207
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1208 {
1209 127235 bool willHitSVPlatform = false;
1210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1212
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1213 {
1214
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1215 {
1216 willHitSVPlatform = true;
1217 break;
1218 }
1219 127235 }
1220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1221 {
1222 y+=fall/100;
1223 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1224 do_fix(y, 16); //Fix to top of SV Ladder
1225 fall = 0;
1226 }
1227 else
1228 {
1229 127235 y+=fall/100;
1230
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1231 109427 fall += (zinit.gravity/100);
1232 }
1233 127235 }
1234 else
1235 {
1236
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 176072 times.
176339 if(fall!=0) // Only fix pos once
1237 {
1238 //y-=(int32_t)y%8; // Fix position
1239 267 do_fix(y, 8); //Fix position
1240 267 }
1241
1242 176339 fall = 0;
1243 }
1244 303574 }
1245 else
1246 {
1247 if(isOnSideviewPlatform())
1248 fall = 0;
1249 else
1250 {
1251 zfix fall_amnt = fall/100;
1252 bool hit = false;
1253 while(fall_amnt >= 1)
1254 {
1255 --fall_amnt;
1256 ++y;
1257 if(isOnSideviewPlatform())
1258 {
1259 y = y.getInt();
1260 fall_amnt = 0;
1261 hit = true;
1262 break;
1263 }
1264 }
1265 if(fall_amnt > 0)
1266 y += fall_amnt;
1267 if(fall_amnt < 0)
1268 {
1269 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1270 hit = true;
1271 }
1272 if(hit)
1273 fall = 0;
1274 else if(fall <= (int32_t)zinit.terminalv)
1275 fall += (zinit.gravity/100);
1276 }
1277 }
1278 303574 }
1279 else
1280 {
1281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9611530 times.
9611530 if (!(moveflags & move_no_fake_z))
1282 {
1283
2/2
✓ Branch 0 taken 5058628 times.
✓ Branch 1 taken 4552902 times.
9611530 if(fakefall!=0)
1284 4552902 fakez-=(fakefall/100);
1285
1286
2/2
✓ Branch 0 taken 4552902 times.
✓ Branch 1 taken 5058628 times.
9611530 if(fakez<0)
1287 4552902 fakez = fakefall = 0;
1288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5058628 times.
5058628 else if(fakefall <= (int32_t)zinit.terminalv)
1289 5058628 fakefall += (zinit.gravity/100);
1290
1291
5/6
✓ Branch 0 taken 9611530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5058628 times.
✓ Branch 3 taken 4552902 times.
✓ Branch 4 taken 4567130 times.
✓ Branch 5 taken 491498 times.
9611530 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1292 9611530 }
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9611530 times.
9611530 if (!(moveflags & move_no_real_z))
1294 {
1295
2/2
✓ Branch 0 taken 5479665 times.
✓ Branch 1 taken 4131865 times.
9611530 if(fall!=0)
1296 4131865 z-=(fall/100);
1297
1298
2/2
✓ Branch 0 taken 4118583 times.
✓ Branch 1 taken 5492947 times.
9611530 if(z<0)
1299 4118583 z = fall = 0;
1300
2/2
✓ Branch 0 taken 9167 times.
✓ Branch 1 taken 5483780 times.
5492947 else if(fall <= (int32_t)zinit.terminalv)
1301 5483780 fall += (zinit.gravity/100);
1302
1303
6/6
✓ Branch 0 taken 9570626 times.
✓ Branch 1 taken 40904 times.
✓ Branch 2 taken 5452043 times.
✓ Branch 3 taken 4118583 times.
✓ Branch 4 taken 4962352 times.
✓ Branch 5 taken 489691 times.
9611530 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1304 9611530 }
1305
1306 }
1307 9915104 }
1308
4/4
✓ Branch 0 taken 37428166 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 9195313 times.
✓ Branch 3 taken 28232853 times.
37824259 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1309 {
1310
8/10
✓ Branch 0 taken 9168816 times.
✓ Branch 1 taken 26497 times.
✓ Branch 2 taken 9129158 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9129158 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9168816 times.
✓ Branch 8 taken 9129158 times.
✓ Branch 9 taken 9129158 times.
9195313 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1311 {
1312 9129158 fallCombo = check_pits();
1313 9129158 }
1314 27453629 }
1315
4/4
✓ Branch 0 taken 37428166 times.
✓ Branch 1 taken 18654409 times.
✓ Branch 2 taken 146615 times.
✓ Branch 3 taken 37281551 times.
56082575 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1316 {
1317
8/10
✓ Branch 0 taken 142669 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141616 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141616 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142669 times.
✓ Branch 8 taken 141616 times.
✓ Branch 9 taken 141616 times.
146615 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1318 {
1319 141616 drownCombo = check_water();
1320 141616 }
1321 429847 }
1322
1323 56365807 runKnockback(); //scripted knockback handling
1324
1325 // clk is incremented here
1326
2/2
✓ Branch 0 taken 54061115 times.
✓ Branch 1 taken 2304692 times.
56365807 if(++clk >= frate)
1327 2304692 clk=0;
1328
1329 // hit and death handling
1330
2/2
✓ Branch 0 taken 1240477 times.
✓ Branch 1 taken 55125330 times.
56365807 if(hclk>0)
1331 1240477 --hclk;
1332
1333
2/2
✓ Branch 0 taken 676316 times.
✓ Branch 1 taken 55689491 times.
56365807 if(stunclk>0)
1334 676316 --stunclk;
1335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56365807 times.
56365807 if ( frozenclock > 0 )
1336 --frozenclock;
1337
1338
5/6
✓ Branch 0 taken 13488 times.
✓ Branch 1 taken 56352319 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 13382 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
56365807 if(ceiling && z <= 0 && fakez <= 0)
1339 106 ceiling = false;
1340
1341 56365807 try_death();
1342
1343 56365807 scored=false;
1344
1345 56365807 ++c_clk;
1346
1347 //Run its script
1348
2/2
✓ Branch 0 taken 18566365 times.
✓ Branch 1 taken 37799442 times.
56365807 if (!didScriptThisFrame)
1349 {
1350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37799442 times.
37799442 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1351 {
1352 return 0; //Avoid NULLPO if this object deleted itself
1353 }
1354 37799442 }
1355
1356 // returns true when enemy is defeated
1357 56365807 return Dead(index);
1358 56368361 }
1359
1360 38578693 bool enemy::setSolid(bool set)
1361 {
1362
1/2
✓ Branch 0 taken 38578693 times.
✗ Branch 1 not taken.
38578693 bool actual = set && !isSubmerged();
1363 38578693 bool ret = solid_object::setSolid(actual);
1364 38578693 solid = set;
1365 38578693 return ret;
1366 }
1367 void enemy::doContactDamage(int32_t hdir)
1368 {
1369 Hero.hithero(guys.find(this), hdir);
1370 }
1371
1372 22405 void enemy::solid_push(solid_object *obj)
1373 {
1374
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1376 22405 zfix dx, dy;
1377 22405 int32_t hdir = -1;
1378 22405 solid_push_int(obj,dx,dy,hdir,true);
1379
1380
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1381
1382 263 bool t = obj->getTempNonsolid();
1383 263 obj->setTempNonsolid(true);
1384
1385 263 int32_t ydir = dy > 0 ? down : up;
1386 263 int32_t xdir = dx > 0 ? right : left;
1387
1388 263 auto special = isflier(id) ? spw_floater : spw_none;
1389
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1390 {
1391 //Crushed?
1392 7 }
1393
1394 263 obj->setTempNonsolid(t);
1395 22405 }
1396 22405 bool enemy::is_unpushable() const
1397 {
1398 22405 return isSubmerged();
1399 }
1400 22087 bool enemy::sideview_mode() const
1401 {
1402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1403 }
1404
1405 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1406 {
1407 3234 int32_t yg = (special==spw_floater)?8:0;
1408 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1409
1410
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1411 4732 return true;
1412
1413 3238 bool isInDungeon = isdungeon();
1414
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1415 {
1416
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1417 1199 return true;
1418
1419
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1420
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1421 return true;
1422 595 }
1423
1424
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1425 {
1426
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1427
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1428 return true;
1429 62 }
1430
1431
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1432 {
1433 case spw_clipbottomright:
1434 if(dy>=128 || dx>=208) return true;
1435 break;
1436 case spw_clipright:
1437 break; //if(x>=208) return true; break;
1438
1439 case spw_wizzrobe: // fall through
1440 case spw_floater: // Special case for fliers and wizzrobes - hack!
1441 {
1442
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1443 {
1444
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1445
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1446 595 }
1447 857 return false;
1448 }
1449 }
1450
1451 dx&=(special==spw_halfstep)?(~7):(~15);
1452 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1453
1454 if(special==spw_water)
1455 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1456
1457 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1458 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1459 870 }
1460
1461 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1462 {
1463 6575 bool kb = false;
1464 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1465
1466
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1467 return true;
1468
1469
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon())
1470 {
1471
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=144))
1472 return true;
1473
1474
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=224))
1475 return true;
1476 1513 }
1477
1478
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1479 {
1480
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1481
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1482 return true;
1483 6575 }
1484
1485
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1486 {
1487
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1489 }
1490 else
1491 {
1492
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1493
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1494
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1496 }
1497 6575 }
1498
1499 32455765 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1500 {
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32455765 times.
32455765 if(moveflags & move_new_movement)
1502 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1503 32455765 int32_t yg = (special==spw_floater)?8:0;
1504 32455765 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1505
2/2
✓ Branch 0 taken 3703972 times.
✓ Branch 1 taken 28751793 times.
32455765 switch(dir)
1506 {
1507 case l_down:
1508 case r_down:
1509 case down:
1510 case 11: //r_down
1511 case 12: //down
1512 case 13: //l_down
1513 {
1514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3703972 times.
3703972 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1515 {
1516
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3703964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3703972 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1517 {
1518 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1519
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1520 8 }
1521 3703972 }
1522 3703972 break;
1523 }
1524 }
1525
2/2
✓ Branch 0 taken 3704791 times.
✓ Branch 1 taken 28750974 times.
32455765 switch(dir)
1526 {
1527 case r_up:
1528 case r_down:
1529 case right:
1530 case 9: //r_up
1531 case 10: //right
1532 case 11: //r_down
1533 {
1534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704791 times.
3704791 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1535 {
1536
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3704788 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3704791 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1537 {
1538 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1539
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1540 3 }
1541 3704791 }
1542 3704791 break;
1543 }
1544 }
1545 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1546
1547
10/10
✓ Branch 0 taken 22401718 times.
✓ Branch 1 taken 10054047 times.
✓ Branch 2 taken 8752429 times.
✓ Branch 3 taken 1301618 times.
✓ Branch 4 taken 10016968 times.
✓ Branch 5 taken 37079 times.
✓ Branch 6 taken 9993841 times.
✓ Branch 7 taken 23127 times.
✓ Branch 8 taken 22454590 times.
✓ Branch 9 taken 32448431 times.
32455765 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1548 44916514 return true;
1549
1550 32448431 bool isInDungeon = isdungeon();
1551
4/4
✓ Branch 0 taken 3927169 times.
✓ Branch 1 taken 28521262 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3915413 times.
32448431 if(isInDungeon || special==spw_wizzrobe)
1552 {
1553
8/8
✓ Branch 0 taken 5892093 times.
✓ Branch 1 taken 22640925 times.
✓ Branch 2 taken 5667626 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820209 times.
✓ Branch 5 taken 17045183 times.
✓ Branch 6 taken 5820022 times.
✓ Branch 7 taken 187 times.
28533018 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1554 11487648 return true;
1555
1556
8/8
✓ Branch 0 taken 5739730 times.
✓ Branch 1 taken 11305640 times.
✓ Branch 2 taken 5573275 times.
✓ Branch 3 taken 166455 times.
✓ Branch 4 taken 5688191 times.
✓ Branch 5 taken 5783904 times.
✓ Branch 6 taken 5687237 times.
✓ Branch 7 taken 954 times.
17045370 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1557
2/2
✓ Branch 0 taken 113868 times.
✓ Branch 1 taken 94 times.
11260512 if(special!=spw_door) // walk in door way
1558 113868 return true;
1559 5784952 }
1560
1561
6/6
✓ Branch 0 taken 3100399 times.
✓ Branch 1 taken 6599966 times.
✓ Branch 2 taken 750062 times.
✓ Branch 3 taken 2350337 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 698832 times.
9700365 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1562 {
1563
4/4
✓ Branch 0 taken 3042752 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3041800 times.
6091019 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1564
4/4
✓ Branch 0 taken 3042569 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3041850 times.
✓ Branch 3 taken 719 times.
3042752 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1565 7369 return true;
1566 3041800 }
1567
1568
4/4
✓ Branch 0 taken 7508153 times.
✓ Branch 1 taken 2178589 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9692996 switch(special)
1569 {
1570 case spw_clipbottomright:
1571
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=128 || dx>=208) return true;
1572 707 break;
1573 case spw_clipright:
1574 5281 break; //if(input_x>=208) return true; break;
1575
1576 case spw_wizzrobe: // fall through
1577 case spw_floater: // Special case for fliers and wizzrobes - hack!
1578 {
1579
2/2
✓ Branch 0 taken 2866474 times.
✓ Branch 1 taken 4641679 times.
7508153 if(isInDungeon)
1580 {
1581
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= 144) return true;
1582
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= 224) return true;
1583 4639539 }
1584 7506013 return false;
1585 }
1586 }
1587
1588 2184577 dx&=(special==spw_halfstep)?(~7):(~15);
1589
2/2
✓ Branch 0 taken 486587 times.
✓ Branch 1 taken 1697990 times.
2184577 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1590
1591
2/2
✓ Branch 0 taken 414391 times.
✓ Branch 1 taken 1770186 times.
2184577 if(special==spw_water)
1592
2/2
✓ Branch 0 taken 16741 times.
✓ Branch 1 taken 397650 times.
414391 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1593
1594
2/2
✓ Branch 0 taken 1711259 times.
✓ Branch 1 taken 58927 times.
1770186 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1595 {
1596
4/4
✓ Branch 0 taken 1227868 times.
✓ Branch 1 taken 483391 times.
✓ Branch 2 taken 1217831 times.
✓ Branch 3 taken 10037 times.
2929090 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1597
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203251 times.
1217831 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1598 }
1599 else
1600 {
1601
4/4
✓ Branch 0 taken 42434 times.
✓ Branch 1 taken 16493 times.
✓ Branch 2 taken 42170 times.
✓ Branch 3 taken 264 times.
101097 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1602
3/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 41807 times.
✗ Branch 3 not taken.
42170 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1603
4/4
✓ Branch 0 taken 36572 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 36557 times.
✓ Branch 3 taken 15 times.
41807 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1604
2/2
✓ Branch 0 taken 36254 times.
✓ Branch 1 taken 303 times.
36557 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1605 }
1606 10079707 }
1607
1608 383430 bool enemy::isOnSideviewPlatform()
1609 {
1610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1612
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383430 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1613 return false;
1614
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1616
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1617 {
1618
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1619
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1621 47357 }
1622 168001 return false;
1623 383430 }
1624
1625 // Stops playing the given sound only if there are no enemies left to play it
1626 765995 void enemy::stop_bgsfx(int32_t index)
1627 {
1628
2/2
✓ Branch 0 taken 750885 times.
✓ Branch 1 taken 15110 times.
765995 if(bgsfx<=0)
1629 750885 return;
1630
1631 // Look for other enemies with the same bgsfx
1632
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1633 {
1634
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1635 6304 return;
1636 46690 }
1637
1638 8806 stop_sfx(bgsfx);
1639 765995 }
1640
1641
1642 // to allow for different sfx on defeating enemy
1643 40248 void enemy::death_sfx()
1644 {
1645
2/2
✓ Branch 0 taken 39964 times.
✓ Branch 1 taken 284 times.
40248 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1646 40248 }
1647
1648 void enemy::move(zfix dx,zfix dy)
1649 {
1650 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1651 {
1652 switch(family)
1653 {
1654 case eeFIRE:
1655 case eeOTHER:
1656 return;
1657 default: break;
1658 }
1659 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1660 }
1661 */
1662 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1663 {
1664 x+=dx;
1665 y+=dy;
1666 }
1667 }
1668
1669 18327343 void enemy::move(zfix s)
1670 {
1671 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1672 {
1673 switch(family)
1674 {
1675 case eeFIRE:
1676 case eeOTHER:
1677 return;
1678 default: break;
1679 }
1680 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1681 }*/
1682
9/10
✓ Branch 0 taken 18327304 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 18247542 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
18327343 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1683 {
1684 18326449 sprite::move(s);
1685 18326449 }
1686 18327343 }
1687
1688 43683 void enemy::leave_item()
1689 {
1690 43683 int32_t drop_item = select_dropitem(item_set, x, y);
1691 43683 int32_t thedropset = item_set;
1692
1693 43683 std::vector<int32_t> &ev = FFCore.eventData;
1694 43683 ev.clear();
1695 43683 ev.push_back(getUID());
1696 43683 ev.push_back(drop_item*10000);
1697 43683 ev.push_back(thedropset*10000);
1698
1699 43683 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1700 43683 drop_item = vbound(ev[1] / 10000,-2,255);
1701 43683 thedropset = ev[2] / 10000;
1702 43683 ev.clear();
1703
1/2
✓ Branch 0 taken 43683 times.
✗ Branch 1 not taken.
43683 if(drop_item == -2)
1704 {
1705 drop_item = select_dropitem(thedropset,x,y);
1706 }
1707
1708
6/6
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 27254 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15512 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43683 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1709 {
1710 item* itm;
1711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16260 times.
16260 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1712 {
1713 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1714 }
1715 else
1716 {
1717
8/14
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 14631 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1629 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1629 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1629 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1629 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1629 times.
✗ Branch 13 not taken.
16260 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1718
4/8
✓ Branch 0 taken 14631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14631 times.
✗ Branch 7 not taken.
14631 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1719 }
1720 16260 itm->from_dropset = thedropset;
1721 16260 items.add(itm);
1722
1723 16260 ev.push_back(getUID());
1724 16260 ev.push_back(itm->getUID());
1725
1726 16260 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1727 16260 ev.clear();
1728 16260 }
1729 43683 }
1730
1731 // auomatically kill off enemy (for rooms with ringleaders)
1732 397 void enemy::kickbucket()
1733 {
1734
3/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 365 times.
✗ Branch 3 not taken.
397 if(!superman && !(flags&guy_ignore_kill_all))
1735 365 hp=-1000; // don't call death_sfx()
1736 397 }
1737
1738 21250 bool enemy::isSubmerged() const
1739 {
1740 21250 return submerged;
1741 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1742 }
1743
1744 20952 void enemy::FireBreath(bool seekhero)
1745 {
1746
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1747 return;
1748
1749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1750 {
1751 dmisc1 = e1tEACHTILE;
1752 FireWeapon();
1753 return;
1754 }
1755
1756 20952 float fire_angle=0.0;
1757 20952 int32_t wx=0, wy=0, wdir=dir;
1758
1759
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1760 {
1761
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1762 {
1763 case down:
1764 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1765 3079 wx=x;
1766 3079 wy=y+8;
1767 3079 break;
1768
1769 case -1:
1770 case up:
1771 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1772 3297 wx=x;
1773 3297 wy=y-8;
1774 3297 break;
1775
1776 case left:
1777 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1778 5287 wx=x-8;
1779 5287 wy=y;
1780 5287 break;
1781
1782 case right:
1783 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1784 4208 wx=x+8;
1785 4208 wy=y;
1786 4208 break;
1787 }
1788
1789
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1790 {
1791
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1797
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1798
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1799 15735 }
1800 15871 }
1801 else
1802 {
1803 5081 wx = x;
1804 5081 wy = y;
1805 }
1806
1807
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1808 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1809
1810 20952 int32_t i=Ewpns.Count()-1;
1811 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1812 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1813
1814
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1815 {
1816 7957 ew->angular=true;
1817 7957 ew->angle=fire_angle;
1818 7957 }
1819
1820
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1821 {
1822 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1824 20359 }
1825
1826
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1827 {
1828 766199 Ewpns.swap(j,j-1);
1829 766199 }
1830 20952 }
1831
1832 44653 void enemy::FireWeapon()
1833 {
1834 /*
1835 * Type:
1836 * 0x01: Boss fireball
1837 * 0x02: Seeks Hero
1838 * 0x04: Fast projectile
1839 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1840 */
1841
1842
2/2
✓ Branch 0 taken 44522 times.
✓ Branch 1 taken 131 times.
44653 if (wpn < 1) return;
1843
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44522 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1844 return;
1845
1846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44522 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1847 dmisc1 = e1tEACHTILE;
1848
1849 44522 int32_t xoff = 0;
1850 44522 int32_t yoff = 0;
1851
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1852 {
1853 xoff += (hit_width/2)-8;
1854 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1855 }
1856
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1857 {
1858 yoff += (hit_height/2)-8;
1859 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1860 }
1861
1862
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41523 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44522 switch(dmisc1)
1863 {
1864 case e1t5SHOTS: //BS-Aquamentus
1865 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1866 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1867 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1868 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1869
1870 [[fallthrough]];
1871 case e1t3SHOTSFAST:
1872 case e1t3SHOTS: //Aquamentus
1873
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1874 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1875
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1876 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877
1878 [[fallthrough]];
1879 default:
1880
12/20
✓ Branch 0 taken 42169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42169 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42169 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42169 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42164 times.
✓ Branch 12 taken 42169 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23931 times.
✓ Branch 16 taken 42169 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42169 times.
✗ Branch 19 not taken.
42169 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1881 42169 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1882 42169 sfx(wpnsfx(wpn),pan(int32_t(x)));
1883 42169 break;
1884
1885 case e1tSLANT:
1886 {
1887 416 int32_t slant = 0;
1888
1889
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1890 246 slant = left;
1891
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1892 117 slant = right;
1893
1894
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1895 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1896 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1897 330 break;
1898 }
1899
1900 case e1t8SHOTS: //Fire Wizzrobe
1901
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1902 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1903 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1904
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1905 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1906 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1907
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1908 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1909 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1910
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1912 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1913
1914 [[fallthrough]];
1915 case e1t4SHOTS: //Stalfos 3
1916
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1917 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1919
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1920 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1922
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1923 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1924 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1925
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1927 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1928 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1929 1937 break;
1930
1931 case e1tSUMMON: // Bat Wizzrobe
1932 {
1933 if(dmisc4==0) break; // Summon 0
1934
1935 int32_t bc=0;
1936
1937 for(int32_t gc=0; gc<guys.Count(); gc++)
1938 {
1939 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1940 {
1941 ++bc;
1942 }
1943 }
1944
1945 if(bc<=40) // Not too many enemies
1946 {
1947 int32_t kids = guys.Count();
1948 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1949
1950 for(int32_t i=0; i<bats; i++)
1951 {
1952 if(addchild(x,y,dmisc3,-10, this->script_UID))
1953 {
1954 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1955
1956 }
1957 }
1958
1959 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1960 }
1961
1962 break;
1963 }
1964
1965 case e1tSUMMONLAYER: // Summoner
1966 {
1967 if(count_layer_enemies()==0)
1968 {
1969 break;
1970 }
1971
1972 int32_t kids = guys.Count();
1973
1974 if(kids<40)
1975 {
1976 int32_t newguys=(zc_oldrand()%3)+1;
1977 bool summoned=false;
1978
1979 for(int32_t i=0; i<newguys; i++)
1980 {
1981 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
1982 int32_t x2=0;
1983 int32_t y2=0;
1984
1985 for(int32_t k=0; k<20; ++k)
1986 {
1987 x2=16*((zc_oldrand()%12)+2);
1988 y2=16*((zc_oldrand()%7)+2);
1989
1990 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1991 {
1992 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
1993 {
1994 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1995 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
1996 {
1997 ((enemy*)guys.spr(kids+i))->fakez = 64;
1998 ((enemy*)guys.spr(kids+i))->z = 0;
1999 }
2000 }
2001
2002 summoned=true;
2003 break;
2004 }
2005 }
2006 }
2007
2008 if(summoned)
2009 {
2010 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2011 }
2012 }
2013
2014 break;
2015 }
2016 }
2017 44567 }
2018
2019
2020 // Hit the shield(s)?
2021 // Apparently, this function is only used for hookshots...
2022 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2023 {
2024
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2025 834 return false;
2026
2027 1933 bool ret = false;
2028
2029 // TODO: There must be some bitwise operations that can simplify this...
2030
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2031
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2032
2033
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2034
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2035
2036 1933 return ret;
2037 2767 }
2038
2039
2040 //! Weapon Editor for 2.6
2041 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2042
2043
2044 //converts a wqeapon ID to its defence index.
2045 126847 int32_t weaponToDefence(int32_t wid)
2046 {
2047
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64405 times.
✓ Branch 2 taken 9432 times.
✓ Branch 3 taken 25029 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3146 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1217 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2036 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 26 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
126847 switch(wid)
2048 {
2049 case wNone: return -1;
2050 64405 case wSword: return edefSWORD;
2051 9432 case wBeam: return edefBEAM;
2052 25029 case wBrang: return edefBRANG;
2053 4207 case wBomb: return edefBOMB;
2054 37 case wSBomb: return edefSBOMB;
2055 48 case wLitBomb: return edefBOMB;
2056 case wLitSBomb: return edefSBOMB;
2057 3146 case wArrow: return edefARROW;
2058 9836 case wFire: return edefFIRE;
2059 case wWhistle:
2060 {
2061 return edefWhistle;
2062 }
2063 case wBait: return edefBAIT;
2064 269 case wWand: return edefWAND;
2065 1217 case wMagic: return edefMAGIC;
2066 case wCatching: return -1;
2067 case wWind: return edefWIND;
2068 512 case wRefMagic: return edefREFMAGIC;
2069 1459 case wRefFireball: return edefREFBALL;
2070 case wRefRock: return edefREFROCK;
2071 2036 case wHammer: return edefHAMMER;
2072 2767 case wHookshot: return edefHOOKSHOT;
2073 610 case wHSHandle: return edefHOOKSHOT;
2074 case wHSChain: return edefHOOKSHOT;
2075 240 case wSSparkle: return edefSPARKLE;
2076 469 case wFSparkle: return edefSPARKLE;
2077 case wSmack: return -1; // is this the candle object?
2078 case wPhantom: return -1; //engine created visual effects.
2079 case wCByrna: return edefBYRNA;
2080 19 case wRefBeam: return edefREFBEAM;
2081 case wStomp: return edefSTOMP;
2082 26 case wScript1: return edefSCRIPT01;
2083 case wScript2: return edefSCRIPT02;
2084 12 case wScript3: return edefSCRIPT03;
2085 77 case wScript4: return edefSCRIPT04;
2086 case wScript5: return edefSCRIPT05;
2087 case wScript6: return edefSCRIPT06;
2088 case wScript7: return edefSCRIPT07;
2089 case wScript8: return edefSCRIPT08;
2090 case wScript9: return edefSCRIPT09;
2091 993 case wScript10: return edefSCRIPT10;
2092 case wIce: return edefICE;
2093 case wSound: return edefSONIC;
2094 1 case wThrown: return edefTHROWN;
2095 case wRefArrow: return edefREFARROW;
2096 case wRefFire: return edefREFFIRE;
2097 case wRefFire2: return edefREFFIRE2;
2098 //case wPot: return edefPOT;
2099 // case wLitZap: return edefELECTRIC;
2100 // case wZ3Sword: return edefZ3SWORD;
2101 // case wLASWord: return edefLASWORD;
2102 // case wSpinAttk: return edefSPINATTK;
2103 // case wShield: return edefSHIELD;
2104 // case wTrowel: return edefTROWEL;
2105
2106 default: return -1;
2107 }
2108 126847 }
2109
2110 126847 int32_t getDefType(weapon *w)
2111 {
2112 126847 int32_t id = getWeaponID(w);
2113 126847 int32_t edef = weaponToDefence(id);
2114
2/2
✓ Branch 0 taken 123470 times.
✓ Branch 1 taken 3377 times.
126847 if(edef == edefHOOKSHOT)
2115 {
2116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2117 return edefSwitchHook;
2118 3377 }
2119 126847 return edef;
2120 126847 }
2121
2122 225898 int32_t getWeaponID(weapon *w)
2123 {
2124 225898 int32_t usewpn = w->useweapon;
2125
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 225668 times.
225898 return (usewpn > 0) ? usewpn : w->id;
2126 }
2127
2128 126847 int32_t enemy::resolveEnemyDefence(weapon *w)
2129 {
2130 //sword edef is 9, but we're reading it at 0
2131 //,
2132 126847 int32_t weapondef = 0;
2133 126847 int32_t wdeftype = getDefType(w);
2134 126847 int32_t usedef = w->usedefence;
2135
2136
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
126847 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2137 {
2138 weapondef = usedef*-1;
2139 }
2140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126847 times.
126847 else if(unsigned(wdeftype) < edefLAST255)
2141 {
2142 126847 weapondef = wdeftype;
2143 126847 }
2144 126847 return weapondef;
2145 }
2146
2147 137389 byte get_def_ignrflag(int32_t edef)
2148 {
2149
3/3
✓ Branch 0 taken 114463 times.
✓ Branch 1 taken 3664 times.
✓ Branch 2 taken 19262 times.
137389 switch(edef)
2150 {
2151 case edIGNORE:
2152 case edIGNOREL1:
2153 case edSTUNORIGNORE:
2154 19262 return WPNUNB_IGNR;
2155 case edSTUNORCHINK:
2156 case edCHINK:
2157 case edCHINKL1:
2158 case edCHINKL2:
2159 case edCHINKL4:
2160 case edCHINKL6:
2161 case edCHINKL8:
2162 case edCHINKL10:
2163 case edLEVELCHINK2:
2164 case edLEVELCHINK3:
2165 case edLEVELCHINK4:
2166 case edLEVELCHINK5:
2167 3664 return WPNUNB_BLOCK;
2168 }
2169 114463 return 0;
2170 137389 }
2171
2172 137389 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2173 {
2174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137389 times.
137389 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2175 switch(edef)
2176 {
2177 case edIGNORE:
2178 case edIGNOREL1:
2179 case edCHINK:
2180 case edCHINKL1:
2181 case edCHINKL2:
2182 case edCHINKL4:
2183 case edCHINKL6:
2184 case edCHINKL8:
2185 case edCHINKL10:
2186 case edLEVELCHINK2:
2187 case edLEVELCHINK3:
2188 case edLEVELCHINK4:
2189 case edLEVELCHINK5:
2190 return edNORMAL;
2191 case edSTUNORIGNORE:
2192 case edSTUNORCHINK:
2193 return edSTUNONLY;
2194 }
2195 return edef;
2196 137389 }
2197
2198 // Do we do damage?
2199 // 0: takehit returns 0
2200 // 1: takehit returns 1
2201 // -1: do damage
2202 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2203 125854 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2204 {
2205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125854 times.
125854 if(switch_hooked) return 0;
2206 125854 int32_t tempx = x;
2207 125854 int32_t tempy = y;
2208 125854 int32_t the_defence = 0;
2209
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2210 {
2211 the_defence = edef*-1; //A specific defence type.
2212 }
2213 125854 else the_defence = defense[edef];
2214
2215 125854 the_defence = conv_edef_unblockable(the_defence, unblockable);
2216
2217
3/4
✓ Branch 0 taken 6557 times.
✓ Branch 1 taken 119297 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6557 times.
125854 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2218 {
2219
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6550 times.
✓ Branch 2 taken 7 times.
6557 switch(the_defence)
2220 {
2221 case edIGNORE:
2222 7 return 0;
2223 case edIGNOREL1:
2224 case edSTUNORIGNORE:
2225 if(*power <= 0)
2226 return 0;
2227 }
2228 6550 sfx(WAV_CHINK,pan(int32_t(x)));
2229 6550 return 1;
2230 }
2231
2232 119297 int32_t new_id = id;
2233 119297 int32_t effect_type = dmisc15;
2234 119297 int32_t delay_timer = 90;
2235 119297 enemy *gleeok = NULL;
2236 119297 enemy *ptra = NULL;
2237 119297 int32_t c = 0;
2238
2239
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 930 times.
✓ Branch 13 taken 17324 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2179 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93072 times.
119297 switch(the_defence)
2240 {
2241 case edREPLACE:
2242 {
2243 sclk = 0;
2244 if ( dmisc16 > 0 ) new_id = dmisc16;
2245 else new_id = id+1;
2246 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2247 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2248 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2249
2250 //Z_scripterrlog("new id is %d\n", new_id);
2251 switch(guysbuf[new_id&0xFFF].family)
2252 {
2253 //Fixme: possible enemy memory leak. (minor)
2254 case eeWALK:
2255 {
2256 enemy *e = new eStalfos(x,y,new_id,clk);
2257 guys.add(e);
2258 }
2259 break;
2260
2261 case eeLEV:
2262 {
2263 enemy *e = new eLeever(x,y,new_id,clk);
2264 guys.add(e);
2265 }
2266 break;
2267
2268 case eeTEK:
2269 {
2270 enemy *e = new eTektite(x,y,new_id,clk);
2271 guys.add(e);
2272 }
2273 break;
2274
2275 case eePEAHAT:
2276 {
2277 enemy *e = new ePeahat(x,y,new_id,clk);
2278 guys.add(e);
2279 }
2280 break;
2281
2282 case eeZORA:
2283 {
2284 enemy *e = new eZora(x,y,new_id,clk);
2285 guys.add(e);
2286 }
2287 break;
2288
2289 case eeGHINI:
2290 {
2291 enemy *e = new eGhini(x,y,new_id,clk);
2292 guys.add(e);
2293 }
2294 break;
2295
2296 case eeKEESE:
2297 {
2298 enemy *e = new eKeese(x,y,new_id,clk);
2299 guys.add(e);
2300 }
2301 break;
2302
2303 case eeWIZZ:
2304 {
2305 enemy *e = new eWizzrobe(x,y,new_id,clk);
2306 guys.add(e);
2307 }
2308 break;
2309
2310 case eePROJECTILE:
2311 {
2312 enemy *e = new eProjectile(x,y,new_id,clk);
2313 guys.add(e);
2314 }
2315 break;
2316
2317 case eeWALLM:
2318 {
2319 enemy *e = new eWallM(x,y,new_id,clk);
2320 guys.add(e);
2321 }
2322 break;
2323
2324 case eeAQUA:
2325 {
2326 enemy *e = new eAquamentus(x,y,new_id,clk);
2327 guys.add(e);
2328 e->x = x;
2329 e->y = y;
2330 }
2331 break;
2332
2333 case eeMOLD:
2334 {
2335 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2336 guys.add(e);
2337 e->x = x;
2338 e->y = y;
2339 }
2340 break;
2341
2342 case eeMANHAN:
2343 {
2344 enemy *e = new eManhandla(x,y,new_id,clk);
2345 guys.add(e);
2346 e->x = x;
2347 e->y = y;
2348 }
2349 break;
2350
2351 case eeGLEEOK:
2352 {
2353 *power = 0;
2354 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2355 guys.add(gleeok);
2356 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2357 new_id &= 0xFFF;
2358 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2359 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2360 for(int32_t i=0; i<head_cnt; i++)
2361 {
2362 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2363 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2364 {
2365 al_trace("Gleeok head %d could not be created!\n",i+1);
2366
2367 for(int32_t j=0; j<i+1; j++)
2368 {
2369 guys.del(guys.Count()-1);
2370 }
2371
2372 break;
2373 }
2374 else
2375 {
2376 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2377 }
2378
2379 c-=guysbuf[new_id].attributes[3];
2380 //gleeok->x = x;
2381 //gleeok->y = y;
2382 //gleeok = e;
2383 }
2384 return 1;
2385 }
2386
2387 case eeGHOMA:
2388 {
2389 enemy *e = new eGohma(x,y,new_id,clk);
2390 guys.add(e);
2391 e->x = x;
2392 e->y = y;
2393 }
2394 break;
2395
2396 case eeLANM:
2397 {
2398 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2399 guys.add(e);
2400 e->x = x;
2401 e->y = y;
2402 }
2403 break;
2404
2405 case eeGANON:
2406 {
2407 enemy *e = new eGanon(x,y,new_id,clk);
2408 guys.add(e);
2409 e->x = x;
2410 e->y = y;
2411 }
2412 break;
2413
2414 case eeFAIRY:
2415 {
2416 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2417 guys.add(e);
2418 e->x = x;
2419 e->y = y;
2420 }
2421 break;
2422
2423 case eeFIRE:
2424 {
2425 enemy *e = new eFire(x,y,new_id,clk);
2426 guys.add(e);
2427 e->x = x;
2428 e->y = y;
2429 }
2430 break;
2431
2432 case eeOTHER:
2433 {
2434 enemy *e = new eOther(x,y,new_id,clk);
2435 guys.add(e);
2436 e->x = x;
2437 e->y = y;
2438 }
2439 break;
2440
2441 case eeSPINTILE:
2442 {
2443 enemy *e = new eSpinTile(x,y,new_id,clk);
2444 guys.add(e);
2445 e->x = x;
2446 e->y = y;
2447 }
2448 break;
2449
2450 // and these enemies use the misc10/misc2 value
2451 case eeROCK:
2452 {
2453 switch(guysbuf[new_id&0xFFF].attributes[9])
2454 {
2455 case 1:
2456 {
2457 enemy *e = new eBoulder(x,y,new_id,clk);
2458 guys.add(e);
2459 e->x = x;
2460 e->y = y;
2461 }
2462 break;
2463
2464 case 0:
2465 default:
2466 {
2467 enemy *e = new eRock(x,y,new_id,clk);
2468 guys.add(e);
2469 e->x = x;
2470 e->y = y;
2471 }
2472 break;
2473 }
2474
2475 break;
2476 }
2477
2478 case eeTRAP:
2479 {
2480 switch(guysbuf[new_id&0xFFF].attributes[1])
2481 {
2482 case 1:
2483 {
2484 enemy *e = new eTrap2(x,y,new_id,clk);
2485 guys.add(e);
2486 e->x = x;
2487 e->y = y;
2488 }
2489 break;
2490
2491 case 0:
2492 default:
2493 {
2494 enemy *e = new eTrap(x,y,new_id,clk);
2495 guys.add(e);
2496 e->x = x;
2497 e->y = y;
2498 }
2499 break;
2500 }
2501
2502 break;
2503 }
2504
2505 case eeDONGO:
2506 {
2507 switch(guysbuf[new_id&0xFFF].attributes[9])
2508 {
2509 case 1:
2510 {
2511 enemy *e = new eDodongo2(x,y,new_id,clk);
2512 guys.add(e);
2513 e->x = x;
2514 e->y = y;
2515 }
2516 break;
2517
2518 case 0:
2519 default:
2520 {
2521 enemy *e = new eDodongo(x,y,new_id,clk);
2522 guys.add(e);
2523 e->x = x;
2524 e->y = y;
2525 }
2526 break;
2527 }
2528
2529 break;
2530 }
2531
2532 case eeDIG:
2533 {
2534 switch(guysbuf[new_id&0xFFF].attributes[9])
2535 {
2536 case 1:
2537 {
2538 enemy *e = new eLilDig(x,y,new_id,clk);
2539 guys.add(e);
2540 e->x = x;
2541 e->y = y;
2542 }
2543 break;
2544
2545 case 0:
2546 default:
2547 {
2548 enemy *e = new eBigDig(x,y,new_id,clk);
2549 guys.add(e);
2550 e->x = x;
2551 e->y = y;
2552 }
2553 break;
2554 }
2555
2556 break;
2557 }
2558
2559 case eePATRA:
2560 {
2561 switch(guysbuf[new_id&0xFFF].attributes[9])
2562 {
2563 case 1:
2564 {
2565 if (get_qr(qr_HARDCODED_BS_PATRA))
2566 {
2567 enemy *e = new ePatraBS(x,y,new_id,clk);
2568 guys.add(e);
2569 e->x = x;
2570 e->y = y;
2571 break;
2572 }
2573 }
2574 [[fallthrough]];
2575 case 0:
2576 default:
2577 {
2578 enemy *e = new ePatra(x,y,new_id,clk);
2579 guys.add(e);
2580 e->x = x;
2581 e->y = y;
2582 }
2583 break;
2584 }
2585
2586 break;
2587 }
2588
2589 case eeGUY:
2590 {
2591 switch(guysbuf[new_id&0xFFF].attributes[9])
2592 {
2593 case 1:
2594 {
2595 enemy *e = new eTrigger(x,y,new_id,clk);
2596 guys.add(e);
2597 }
2598 break;
2599
2600 case 0:
2601 default:
2602 {
2603 enemy *e = new eNPC(x,y,new_id,clk);
2604 guys.add(e);
2605 }
2606 break;
2607 }
2608
2609 break;
2610 }
2611
2612 case eeSCRIPT01:
2613 case eeSCRIPT02:
2614 case eeSCRIPT03:
2615 case eeSCRIPT04:
2616 case eeSCRIPT05:
2617 case eeSCRIPT06:
2618 case eeSCRIPT07:
2619 case eeSCRIPT08:
2620 case eeSCRIPT09:
2621 case eeSCRIPT10:
2622 case eeSCRIPT11:
2623 case eeSCRIPT12:
2624 case eeSCRIPT13:
2625 case eeSCRIPT14:
2626 case eeSCRIPT15:
2627 case eeSCRIPT16:
2628 case eeSCRIPT17:
2629 case eeSCRIPT18:
2630 case eeSCRIPT19:
2631 case eeSCRIPT20:
2632 {
2633 enemy *e = new eScript(x,y,new_id,clk);
2634 guys.add(e);
2635 e->x = x;
2636 e->y = y;
2637 break;
2638 }
2639
2640
2641 case eeFFRIENDLY01:
2642 case eeFFRIENDLY02:
2643 case eeFFRIENDLY03:
2644 case eeFFRIENDLY04:
2645 case eeFFRIENDLY05:
2646 case eeFFRIENDLY06:
2647 case eeFFRIENDLY07:
2648 case eeFFRIENDLY08:
2649 case eeFFRIENDLY09:
2650 case eeFFRIENDLY10:
2651 {
2652 enemy *e = new eFriendly(x,y,new_id,clk);
2653 guys.add(e);
2654 e->x = x;
2655 e->y = y;
2656 break;
2657 }
2658
2659
2660 default: break;
2661 }
2662
2663 // add segments of segmented enemies
2664 int32_t c=0;
2665
2666 switch(guysbuf[new_id&0xFFF].family)
2667 {
2668 case eeMOLD:
2669 {
2670 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2671 new_id &= 0xFFF;
2672
2673 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2674 {
2675 //christ this is messy -DD
2676 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2677
2678 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2679 {
2680 al_trace("Moldorm segment %d could not be created!\n",i+1);
2681
2682 for(int32_t j=0; j<i+1; j++)
2683 guys.del(guys.Count()-1);
2684
2685 return 0;
2686 }
2687
2688 if(i>0)
2689 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2690
2691
2692 }
2693
2694 break;
2695 }
2696
2697 case eeLANM:
2698 {
2699 new_id &= 0xFFF;
2700 int32_t shft = guysbuf[new_id].attributes[1];
2701 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2702 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2703
2704 if(!guys.add(e))
2705 {
2706 al_trace("Lanmola segment 1 could not be created!\n");
2707 guys.del(guys.Count()-1);
2708 return 0;
2709 }
2710 e->x = x;
2711 e->y = y;
2712
2713
2714
2715 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2716 {
2717 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2718 if(!guys.add(e2))
2719 {
2720 al_trace("Lanmola segment %d could not be created!\n",i+1);
2721
2722 for(int32_t j=0; j<i+1; j++)
2723 guys.del(guys.Count()-1);
2724
2725 return 0;
2726 }
2727 e2->x = x;
2728 e2->y = y;
2729
2730 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2731
2732 }
2733 }
2734 break;
2735
2736 case eeMANHAN:
2737 new_id &= 0xFFF;
2738
2739 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2740 {
2741 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2742 {
2743 al_trace("Manhandla head %d could not be created!\n",i+1);
2744
2745 for(int32_t j=0; j<i+1; j++)
2746 {
2747 guys.del(guys.Count()-1);
2748 }
2749
2750 return 0;
2751 }
2752
2753
2754 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2755 }
2756
2757 break;
2758
2759 case eeGLEEOK:
2760 {
2761 /*
2762 new_id &= 0xFFF;
2763 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2764 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2765 for(int32_t i=0; i<head_cnt; i++)
2766 {
2767 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2768 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2769 {
2770 al_trace("Gleeok head %d could not be created!\n",i+1);
2771
2772 for(int32_t j=0; j<i+1; j++)
2773 {
2774 guys.del(guys.Count()-1);
2775 }
2776
2777 break;
2778 }
2779
2780 c-=guysbuf[new_id].misc4;
2781 */
2782
2783 // }
2784 }
2785 break;
2786
2787
2788 case eePATRA:
2789 {
2790 new_id &= 0xFFF;
2791 int32_t outeyes = 0;
2792 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2793
2794 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2795 {
2796 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2797 {
2798 al_trace("Patra outer eye %d could not be created!\n",i+1);
2799
2800 for(int32_t j=0; j<i+1; j++)
2801 guys.del(guys.Count()-1);
2802
2803 return 0;
2804 }
2805 else
2806 outeyes++;
2807
2808
2809 }
2810
2811 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2812 {
2813 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2814 {
2815 al_trace("Patra inner eye %d could not be created!\n",i+1);
2816
2817 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2818 guys.del(guys.Count()-1);
2819
2820 return 0;
2821 }
2822
2823
2824 }
2825 delete ptra;
2826 break;
2827 }
2828 }
2829
2830
2831
2832 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2833 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2834 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2835 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2836 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2837 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2838 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2839 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2840 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2841 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2842 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2843 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2844 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2845
2846
2847 item_set = 0; //Do not make a drop.
2848
2849 switch(effect_type)
2850 {
2851 case -7:
2852 {
2853 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2854 Lwpns.add(w);
2855 break;
2856 }
2857 case -6:
2858 {
2859 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2860 Lwpns.add(w);
2861 break;
2862 }
2863 case -5:
2864 {
2865 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2866 Lwpns.add(w);
2867 break;
2868 }
2869 case -4:
2870 {
2871 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2872 Lwpns.add(w);
2873 break;
2874 }
2875 case -3: explode(1); break;
2876 case -2: explode(2); break;
2877 case -1: explode(0); break;
2878 case 0: break;
2879
2880 default:
2881 {
2882 //Dummy weapon function
2883 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2884 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2885 Lwpns.add(w);
2886 break;
2887 }
2888 }
2889
2890
2891 yofs = -32768;
2892 switch(guysbuf[new_id&0xFFF].family)
2893 {
2894 case eeGLEEOK:
2895 {
2896 Z_scripterrlog("Replacing a gleeok.\n");
2897 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2898 hp = -999;
2899 tempenemy->hp = -999;
2900 break;
2901
2902 }
2903 default:
2904 hp = -1000; break;
2905 }
2906 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2907 return 1;
2908
2909 }
2910 case edSPLIT:
2911 {
2912 for ( int32_t q = 0; q < dmisc4; q++ )
2913 {
2914 addenemy(
2915 //ex,ey,
2916 x,y,
2917 dmisc3+0x1000,-15);
2918
2919 }
2920 item_set = 0; //Do not make a drop.
2921 hp = -1000;
2922 return -1;
2923
2924 }
2925 case edSUMMON:
2926 {
2927 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2928 for ( int32_t q = 0; q < summon_count; q++ )
2929 {
2930 int32_t x2=16*((zc_oldrand()%12)+2);
2931 int32_t y2=16*((zc_oldrand()%7)+2);
2932 addenemy(
2933 x2,y2,
2934 dmisc3+0x1000,-15);
2935
2936 }
2937 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2938 return -1;
2939
2940 }
2941
2942 case edEXPLODESMALL:
2943 {
2944 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2945 Ewpns.add(ew);
2946 item_set = 0; //Should we make a drop?
2947 hp = -1000;
2948 return -1;
2949 }
2950
2951
2952 case edEXPLODEHARMLESS:
2953 {
2954 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2955 Ewpns.add(ew);
2956 ew->hyofs = -32768;
2957 item_set = 0; //Should we make a drop?
2958 hp = -1000;
2959 return -1;
2960 }
2961
2962
2963 case edEXPLODELARGE:
2964 {
2965 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2966 Ewpns.add(ew);
2967
2968 hp = -1000;
2969 return -1;
2970 }
2971
2972
2973 case edTRIGGERSECRETS:
2974 {
2975 hidden_entrance(0, true, false, -4);
2976 return -1;
2977 }
2978
2979 case edSTUNORCHINK:
2980
3/4
✓ Branch 0 taken 1123 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1123 times.
✗ Branch 3 not taken.
3709 if (stunclk && get_qr(qr_NO_STUNLOCK))
2981 {
2982 sfx(WAV_CHINK,pan(int32_t(x)));
2983 return 1;
2984 }
2985
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1530 times.
2179 else if(*power <= 0)
2986 {
2987 649 sfx(WAV_CHINK,pan(int32_t(x)));
2988 649 return 1;
2989 }
2990 [[fallthrough]];
2991
2992 case edSTUNORIGNORE:
2993
3/4
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1956 times.
✗ Branch 3 not taken.
5967 if (stunclk && get_qr(qr_NO_STUNLOCK))
2994 {
2995 sfx(WAV_CHINK,pan(int32_t(x)));
2996 return 1;
2997 }
2998
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2506 times.
3461 else if(*power <= 0)
2999 955 return 0;
3000 [[fallthrough]];
3001
3002 case edSTUNONLY:
3003
7/10
✓ Branch 0 taken 4368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3821 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4047 times.
✓ Branch 9 taken 321 times.
4368 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3004 {
3005 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3006 321 return 1;
3007 }
3008
3/4
✓ Branch 0 taken 3122 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3122 times.
✗ Branch 3 not taken.
4047 if (stunclk && get_qr(qr_NO_STUNLOCK))
3009 {
3010 sfx(WAV_CHINK,pan(int32_t(x)));
3011 return 1;
3012 }
3013 else
3014 {
3015 4047 stunclk=160;
3016 4047 sfx(WAV_EHIT,pan(int32_t(x)));
3017
3018 4047 return 1;
3019 }
3020
3021 case edCHINKL1:
3022 if(*power >= 1*game->get_hero_dmgmult()) break;
3023 [[fallthrough]];
3024 case edCHINKL2:
3025
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3026 [[fallthrough]];
3027 case edCHINKL4:
3028
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3029 [[fallthrough]];
3030 case edCHINKL6:
3031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3032 [[fallthrough]];
3033 case edCHINKL8:
3034
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3035 [[fallthrough]];
3036 case edCHINKL10:
3037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3038 [[fallthrough]];
3039 case edCHINK:
3040 1041 sfx(WAV_CHINK,pan(int32_t(x)));
3041 1041 return 1;
3042
3043 case edIGNOREL1:
3044 if(*power > 0) break;
3045 [[fallthrough]];
3046
3047 case edIGNORE:
3048 17324 return 0;
3049
3050 case ed1HKO:
3051 492 *power = hp;
3052 492 return -2;
3053
3054 case ed2x:
3055 {
3056
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3057 //int32_t pow = *power;
3058 //*power = vbound((pow*2),0,214747);
3059 71 return -1;
3060 }
3061 case ed3x:
3062 {
3063 *power = zc_max(1,*power*3);
3064 //int32_t pow = *power;
3065 //*power = vbound((pow*3),0,214747);
3066 return -1;
3067 }
3068
3069 case ed4x:
3070 {
3071 *power = zc_max(1,*power*4);
3072 //int32_t pow = *power;
3073 //*power = vbound((pow*4),0,214747);
3074 return -1;
3075 }
3076
3077
3078 case edHEAL:
3079 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3080 //int32_t pow = *power;
3081 //*power = vbound((pow*-1),0,214747);
3082 //break;
3083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3084 158 return -1;
3085 }
3086 /*
3087 case edLEVELDAMAGE:
3088 {
3089 int32_t pow = *power;
3090 int32_t lvl = *level;
3091 *power = vbound((pow*lvl),0,214747);
3092 break;
3093 }
3094 case edLEVELREDUCTION:
3095 {
3096 int32_t pow = *power;
3097 int32_t lvl = *level;
3098 *power = vbound((pow/lvl),0,214747);
3099 break;
3100 }
3101 */
3102
3103 case edQUARTDAMAGE:
3104
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3105
3106 [[fallthrough]];
3107 case edHALFDAMAGE:
3108
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3109 988 break;
3110
3111 case edSWITCH:
3112 {
3113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3115 {
3116 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3117 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3118 return 0;
3119 }
3120 4 hooked_combopos = -1;
3121 4 hooked_layerbits = 0;
3122 4 switching_object = this;
3123 4 switch_hooked = true;
3124 4 Hero.doSwitchHook(game->get_switchhookstyle());
3125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3126 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3127 4 return 1;
3128 }
3129
3130 case 0:
3131 {
3132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93072 times.
93072 if(edef == edefSwitchHook)
3133 return -1;
3134
6/6
✓ Branch 0 taken 19536 times.
✓ Branch 1 taken 73536 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19478 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93072 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3135 {
3136 26 sfx(WAV_CHINK,pan(int32_t(x)));
3137 26 return 1;
3138 }
3139
3140 }
3141 93046 }
3142
3143 94209 return -1;
3144 125854 }
3145
3146 125854 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3147 {
3148
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 int wuid = w?w->getUID():0;
3149
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3150
3151
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 if(fakeweap)
3152 Lwpns.add(w);
3153 125854 std::vector<int32_t> &ev = FFCore.eventData;
3154 125854 ev.clear();
3155 125854 ev.push_back(*power*10000);
3156 125854 ev.push_back(edef*10000);
3157 125854 ev.push_back(unblockable*10000);
3158 125854 ev.push_back(wpnId*10000);
3159 125854 ev.push_back(0);
3160 125854 ev.push_back(getUID());
3161 125854 ev.push_back(wuid);
3162
3163 125854 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3164 125854 *power = ev[0]/10000;
3165 125854 edef = ev[1]/10000;
3166 125854 unblockable = byte(ev[2]/10000);
3167 125854 wpnId = ev[3] / 10000;
3168 125854 bool nullify = ev[4]!=0;
3169 125854 ev.clear();
3170 125854 int ret = 0;
3171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125854 times.
125854 if(!nullify)
3172 {
3173 125854 ret = defendNew(wpnId, power, edef, unblockable);
3174
2/2
✓ Branch 0 taken 32778 times.
✓ Branch 1 taken 93076 times.
125854 if(ret == -1)
3175 {
3176 93076 ev.push_back(*power*10000);
3177 93076 ev.push_back(edef*10000);
3178 93076 ev.push_back(unblockable*10000);
3179 93076 ev.push_back(wpnId*10000);
3180 93076 ev.push_back(0);
3181 93076 ev.push_back(getUID());
3182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93076 times.
93076 ev.push_back(w?w->getUID():0);
3183
3184 93076 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3185 93076 *power = ev[0]/10000;
3186 93076 nullify = ev[4]!=0;
3187 93076 ev.clear();
3188 93076 }
3189 125854 }
3190
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 if(fakeweap)
3191 Lwpns.remove(w);
3192
3193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125854 times.
125854 return nullify ? 0 : ret;
3194 }
3195
3196 99051 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3197 {
3198
2/2
✓ Branch 0 taken 98474 times.
✓ Branch 1 taken 577 times.
99051 if(!realweap) realweap = w;
3199 99051 int32_t wid = getWeaponID(w);
3200
3201 99051 int32_t edef = resolveEnemyDefence(w);
3202
2/2
✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 93219 times.
99051 if(QHeader.zelda_version > 0x250)
3203 5832 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3204
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92226 times.
✗ Branch 2 not taken.
93219 switch(wid)
3205 {
3206 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3207 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3208 993 return defend(wpnId, power, edefSCRIPT);
3209
3210 case wWhistle:
3211 return -1;
3212
3213 default:
3214 92226 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3215 }
3216 99051 }
3217
3218
3219 // Check defenses without actually acting on them.
3220 27424 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3221 {
3222
4/10
✓ Branch 0 taken 15431 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27424 switch(defense[edef])
3223 {
3224 case edSTUNONLY:
3225 474 return false;
3226 case edSTUNORCHINK:
3227 case edCHINK:
3228 15431 return unblockable&WPNUNB_BLOCK;
3229 case edSTUNORIGNORE:
3230 case edIGNORE:
3231 11050 return unblockable&WPNUNB_IGNR;
3232
3233 case edIGNOREL1:
3234 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3235 case edCHINKL1:
3236 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3237
3238 case edCHINKL2:
3239 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3240
3241 case edCHINKL4:
3242 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3243
3244 case edCHINKL6:
3245 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3246
3247 case edCHINKL8:
3248 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3249 }
3250
3251 469 return true;
3252 27424 }
3253
3254 // Do we do damage?
3255 // 0: takehit returns 0
3256 // 1: takehit returns 1
3257 // -1: do damage
3258 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3259 {
3260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3261 {
3262 switch(defense[edef])
3263 {
3264 case edIGNORE:
3265 return 0;
3266 case edIGNOREL1:
3267 case edSTUNORIGNORE:
3268 if(*power <= 0)
3269 return 0;
3270 }
3271
3272 sfx(WAV_CHINK,pan(int32_t(x)));
3273 return 1;
3274 }
3275
3276
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3277 {
3278 case edSTUNORCHINK:
3279 if(*power <= 0)
3280 {
3281 sfx(WAV_CHINK,pan(int32_t(x)));
3282 return 1;
3283 }
3284
3285 [[fallthrough]];
3286 case edSTUNORIGNORE:
3287 if(*power <= 0)
3288 return 0;
3289
3290 [[fallthrough]];
3291 case edSTUNONLY:
3292 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3293 return 1;
3294
3295 stunclk=160;
3296 sfx(WAV_EHIT,pan(int32_t(x)));
3297 return 1;
3298
3299 case edFREEZE:
3300 frozenclock=-1;
3301 //sfx(WAV_FREEZE,pan(int32_t(x)));
3302 return 1;
3303
3304 case edCHINKL1:
3305 if(*power >= 1*game->get_hero_dmgmult()) break;
3306 [[fallthrough]];
3307 case edCHINKL2:
3308 if(*power >= 2*game->get_hero_dmgmult()) break;
3309 [[fallthrough]];
3310 case edCHINKL4:
3311 if(*power >= 4*game->get_hero_dmgmult()) break;
3312 [[fallthrough]];
3313 case edCHINKL6:
3314 if(*power >= 6*game->get_hero_dmgmult()) break;
3315 [[fallthrough]];
3316 case edCHINKL8:
3317 if(*power >= 8*game->get_hero_dmgmult()) break;
3318 [[fallthrough]];
3319 case edCHINKL10:
3320 if(*power >= 10*game->get_hero_dmgmult()) break;
3321 [[fallthrough]];
3322 case edCHINK:
3323 sfx(WAV_CHINK,pan(int32_t(x)));
3324 return 1;
3325 case edTRIGGERSECRETS:
3326 hidden_entrance(0, true, false, -4);
3327 break;
3328
3329 case edIGNOREL1:
3330 if(*power > 0) break;
3331 [[fallthrough]];
3332 case edIGNORE:
3333 800 return 0;
3334
3335 case ed1HKO:
3336 *power = hp;
3337 return -2;
3338
3339 case ed2x:
3340 {
3341 *power = zc_max(1,*power*2);
3342 //int32_t pow = *power;
3343 //*power = vbound((pow*2),0,214747);
3344 return -1;
3345 }
3346 case ed3x:
3347 {
3348 *power = zc_max(1,*power*3);
3349 //int32_t pow = *power;
3350 //*power = vbound((pow*3),0,214747);
3351 return -1;
3352 }
3353
3354 case ed4x:
3355 {
3356 *power = zc_max(1,*power*4);
3357 //int32_t pow = *power;
3358 //*power = vbound((pow*4),0,214747);
3359 return -1;
3360 }
3361
3362
3363 case edHEAL:
3364 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3365 //int32_t pow = *power;
3366 //*power = vbound((pow*-1),0,214747);
3367 //break;
3368 *power = zc_min(0,*power*-1);
3369 return -1;
3370 }
3371 /*
3372 case edLEVELDAMAGE:
3373 {
3374 int32_t pow = *power;
3375 int32_t lvl = *level;
3376 *power = vbound((pow*lvl),0,214747);
3377 break;
3378 }
3379 case edLEVELREDUCTION:
3380 {
3381 int32_t pow = *power;
3382 int32_t lvl = *level;
3383 *power = vbound((pow/lvl),0,214747);
3384 break;
3385 }
3386 */
3387
3388
3389 case edQUARTDAMAGE:
3390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3391
3392 [[fallthrough]];
3393 case edHALFDAMAGE:
3394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3395 7 break;
3396 }
3397
3398 193 return -1;
3399 993 }
3400
3401 // Defend against a particular item class.
3402 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3403 {
3404 int32_t def=-1;
3405
3406 switch(wpnId)
3407 {
3408 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3409 case wBrang:
3410 def = defend(wpnId, power, edefBRANG);
3411 break;
3412
3413 case wHookshot:
3414 def = defend(wpnId, power, edefHOOKSHOT);
3415 break;
3416
3417 // Anyway...
3418 case wBomb:
3419 def = defend(wpnId, power, edefBOMB);
3420 break;
3421
3422 case wSBomb:
3423 def = defend(wpnId, power, edefSBOMB);
3424 break;
3425
3426 case wArrow:
3427 def = defend(wpnId, power, edefARROW);
3428 break;
3429
3430 case wFire:
3431 def = defend(wpnId, power, edefFIRE);
3432 break;
3433
3434 case wWand:
3435 def = defend(wpnId, power, edefWAND);
3436 break;
3437
3438 case wMagic:
3439 def = defend(wpnId, power, edefMAGIC);
3440 break;
3441
3442 case wHammer:
3443 def = defend(wpnId, power, edefHAMMER);
3444 break;
3445
3446 case wSword:
3447 def = defend(wpnId, power, edefSWORD);
3448 break;
3449
3450 case wBeam:
3451 def = defend(wpnId, power, edefBEAM);
3452 break;
3453
3454 case wRefBeam:
3455 def = defend(wpnId, power, edefREFBEAM);
3456 break;
3457
3458 case wRefMagic:
3459 def = defend(wpnId, power, edefREFMAGIC);
3460 break;
3461
3462 case wRefFireball:
3463 def = defend(wpnId, power, edefREFBALL);
3464 break;
3465
3466 case wRefRock:
3467 def = defend(wpnId, power, edefREFROCK);
3468 break;
3469
3470 case wStomp:
3471 def = defend(wpnId, power, edefSTOMP);
3472 break;
3473
3474 case wCByrna:
3475 def = defend(wpnId, power, edefBYRNA);
3476 break;
3477
3478 case wScript1:
3479 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3480 else def = defend(wpnId, power, edefSCRIPT);
3481 break;
3482
3483 case wScript2:
3484 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3485 else def = defend(wpnId, power, edefSCRIPT);
3486 break;
3487
3488 case wScript3:
3489 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3490 else def = defend(wpnId, power, edefSCRIPT);
3491 break;
3492
3493 case wScript4:
3494 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3495 else def = defend(wpnId, power, edefSCRIPT);
3496 break;
3497
3498 case wScript5:
3499 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3500 else def = defend(wpnId, power, edefSCRIPT);
3501 break;
3502
3503 case wScript6:
3504 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3505 else def = defend(wpnId, power, edefSCRIPT);
3506 break;
3507
3508 case wScript7:
3509 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3510 else def = defend(wpnId, power, edefSCRIPT);
3511 break;
3512
3513 case wScript8:
3514 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3515 else def = defend(wpnId, power, edefSCRIPT);
3516 break;
3517
3518 case wScript9:
3519 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3520 else def = defend(wpnId, power, edefSCRIPT);
3521 break;
3522
3523 case wScript10:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wWhistle:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3530 else break;
3531 break;
3532
3533 case wRefArrow:
3534 def = defend(wpnId, power, edefREFARROW);
3535 break;
3536 case wRefFire:
3537 def = defend(wpnId, power, edefREFFIRE);
3538 break;
3539 case wRefFire2:
3540 def = defend(wpnId, power, edefREFFIRE2);
3541 break;
3542
3543 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3544 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3545 //of the ten if the quest version is lower than N.
3546 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3547 //such as bool UseSeparatedScriptDefences. hah.
3548 default:
3549 //if(wpnId>=wScript1 && wpnId<=wScript10)
3550 // {
3551 // def = defend(wpnId, power, edefSCRIPT);
3552 // }
3553 // }
3554
3555 break;
3556 }
3557
3558 return def;
3559 }
3560
3561 // take damage or ignore it
3562 // -1: damage (if any) dealt
3563 // 1: blocked
3564 // 0: weapon passes through unhindered
3565 264485 int32_t enemy::takehit(weapon *w, weapon* realweap)
3566 {
3567
2/4
✓ Branch 0 taken 264485 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264485 times.
264485 if(fallclk||drownclk) return 0;
3568
2/2
✓ Branch 0 taken 69389 times.
✓ Branch 1 taken 195096 times.
264485 if(!realweap) realweap = w;
3569 264485 int32_t wpnId = w->id;
3570 264485 int32_t power = w->power;
3571 264485 int32_t wpnx = w->x;
3572 264485 int32_t wpny = w->y;
3573 264485 int32_t enemyHitWeapon = w->parentitem;
3574 int32_t wpnDir;
3575 264485 int32_t parent_item = w->parentitem;
3576
3577
2/2
✓ Branch 0 taken 264370 times.
✓ Branch 1 taken 115 times.
264485 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3578 {
3579 115 wpnId = w->useweapon;
3580 115 }
3581
3582 // If it's a boomerang that just bounced, use the opposite direction;
3583 // otherwise, it might bypass a shield. This probably won't handle
3584 // every case correctly, but it's better than having shields simply
3585 // not work against boomerangs.
3586
8/8
✓ Branch 0 taken 25075 times.
✓ Branch 1 taken 239410 times.
✓ Branch 2 taken 15575 times.
✓ Branch 3 taken 9500 times.
✓ Branch 4 taken 14357 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3305 times.
✓ Branch 7 taken 11052 times.
264485 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3587 11052 wpnDir = oppositeDir[w->dir];
3588 else
3589 253433 wpnDir = w->dir;
3590
3591
5/8
✓ Branch 0 taken 264485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264485 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8172 times.
✓ Branch 7 taken 271943 times.
264485 if(dying || clk<0 || hclk>0 || superman)
3592 8172 return 0;
3593
3594 //Prevent boomerang from writing to hitby[] for more than one frame.
3595 //This also prevents stunlock.
3596 //if ( stunclk > 0 ) return 0;
3597 //this needs a rule for boomerangs that cannot stunlock!
3598 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3599 //sigh.
3600
3601 271943 int32_t ret = -1;
3602
3603 // This obscure quest rule...
3604
5/6
✓ Branch 0 taken 91703 times.
✓ Branch 1 taken 180240 times.
✓ Branch 2 taken 88200 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88200 times.
271943 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3605 {
3606 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3607 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3608 3503 wpnDir=zc_oldrand()&3;
3609
3610
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3611 {
3612 189 wpnDir=down;
3613 189 }
3614
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3615 {
3616 285 wpnDir=right;
3617 285 }
3618
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3619 {
3620 2064 wpnDir=up;
3621 2064 }
3622 else
3623 {
3624 965 wpnDir=left;
3625 }
3626 3503 }
3627
3628 271943 int32_t xdir = dir;
3629 271943 shieldCanBlock=false;
3630
3631
4/4
✓ Branch 0 taken 260663 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 257896 times.
272671 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3632
6/6
✓ Branch 0 taken 18173 times.
✓ Branch 1 taken 15406 times.
✓ Branch 2 taken 25948 times.
✓ Branch 3 taken 247354 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 247296 times.
260663 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3633
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246312 times.
✓ Branch 2 taken 728 times.
✓ Branch 3 taken 245584 times.
247296 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3634 )
3635 // The hammer should already be dealt with by subclasses (Walker etc.)
3636 {
3637
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5748 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 1488 times.
45891 switch(wpnId)
3638 {
3639 // Weapons which shields protect against
3640 case wSword:
3641 case wWand:
3642
2/2
✓ Branch 0 taken 5746 times.
✓ Branch 1 taken 2 times.
5750 if(Hero.getCharging()>0)
3643 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3644
3645 [[fallthrough]];
3646 case wHookshot:
3647 case wHSHandle:
3648 case wBrang:
3649 6120 shieldCanBlock=true;
3650 6458 break;
3651
3652 case wBeam:
3653 case wRefBeam:
3654 // Mirror shielded enemies!
3655 #if 0
3656 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3657 {
3658 if(wpnId>wEnemyWeapons)
3659 return 0;
3660
3661 sfx(WAV_CHINK,pan(int32_t(x)));
3662 return 1;
3663 }
3664
3665 #endif
3666
3667 [[fallthrough]];
3668 case wRefRock:
3669 case wRefFireball:
3670 case wMagic:
3671 #if 0
3672 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3673 {
3674 sfx(WAV_CHINK,pan(int32_t(x)));
3675 return 3;
3676 }
3677
3678 #endif
3679
3680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(wpnId>wEnemyWeapons)
3681 return 0;
3682
3683 [[fallthrough]];
3684 case wArrow:
3685 380 case wRefArrow:
3686 default:
3687 1868 shieldCanBlock=true;
3688 1868 break;
3689
3690 // Bombs
3691 case wSBomb:
3692 case wBomb:
3693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3694 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3695 {
3696 sfx(WAV_CHINK,pan(int32_t(x)));
3697 return 0;
3698 }
3699 else break;
3700
3701 // Weapons which ignore shields
3702 case wWhistle:
3703 case wHammer:
3704 2 break;
3705
3706 // Weapons which shouldn't be removed by shields
3707 case wLitBomb:
3708 case wLitSBomb:
3709 case wWind:
3710 case wPhantom:
3711 case wSSparkle:
3712 case wBait:
3713 864 return 0;
3714
3715 case wFire:
3716 case wRefFire:
3717 case wRefFire2:
3718 ;
3719 680 }
3720 8670 }
3721
3722
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 97394 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27424 times.
✓ Branch 5 taken 25029 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
265534 switch(wpnId)
3723 {
3724 case wWhistle: //No longer completely ignore whistle weapons! -Z
3725 {
3726
3727
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3728 {
3729 423 return 0; break;
3730 }
3731 else
3732 {
3733 w->power = power = itemsbuf[parent_item].misc5;
3734
3735 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3736
3737 if(def <= 0)
3738 {
3739 if ( def == -2 ) hp -= hp;
3740 else hp -= power;
3741 return def;
3742 }
3743 break;
3744 }
3745 break;
3746 }
3747
3748 case wPhantom:
3749 270 return 0;
3750
3751 case wLitBomb:
3752 case wLitSBomb:
3753 case wBait:
3754 case wWind:
3755 case wSSparkle:
3756 103171 return 0;
3757
3758 case wFSparkle:
3759
3760 // Only take sparkle damage if the sparkle's parent item is not
3761 // defended against.
3762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27424 times.
27424 if(enemyHitWeapon > -1)
3763 {
3764 27424 int32_t p = 0;
3765 27424 int32_t f = itemsbuf[enemyHitWeapon].family;
3766
3767
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27424 times.
27424 switch(f)
3768 {
3769 case itype_arrow:
3770 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3771
3772 break;
3773
3774 case itype_cbyrna:
3775 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3776
3777 break;
3778
3779 case itype_brang:
3780
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26955 times.
27424 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3781
3782 469 break;
3783
3784 default:
3785 return 0;
3786 }
3787 469 }
3788
3789 469 wpnId = wSword;
3790 469 power = game->get_hero_dmgmult()>>1;
3791 469 goto fsparkle;
3792 break;
3793
3794 case wBrang:
3795 {
3796 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3797 25029 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3798 //preventing stunlock might be best, here. -Z
3799
2/2
✓ Branch 0 taken 5467 times.
✓ Branch 1 taken 19562 times.
25029 if(def >= 0) return def;
3800
3801 // Not hurt by 0-damage weapons
3802
2/2
✓ Branch 0 taken 3188 times.
✓ Branch 1 taken 16374 times.
19562 if(!(flags & guy_bhit))
3803 {
3804 16374 stunclk=160;
3805
3806
3/4
✓ Branch 0 taken 16374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1305 times.
✓ Branch 3 taken 15069 times.
16374 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3807 {
3808
1/2
✓ Branch 0 taken 1305 times.
✗ Branch 1 not taken.
1305 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3809 1305 goto hitclock;
3810 }
3811
3812 15069 break;
3813 }
3814
3815
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 2793 times.
3188 if(!power)
3816
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3817 else
3818 395 hp-=power;
3819
3820 3188 goto hitclock;
3821 }
3822
3823 case wHookshot:
3824 {
3825 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3826 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3827
3828
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3829
3830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3831
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3832 {
3833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3834 1625 stunclk=160;
3835
3836
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3837 {
3838
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3839 549 goto hitclock;
3840 }
3841
3842 1076 break;
3843 }
3844
3845
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3846 else
3847 45 hp-=power;
3848
3849 148 goto hitclock;
3850 }
3851 break;
3852
3853 case wHSHandle:
3854 {
3855
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3856 523 return 0;
3857
3858
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3859
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3860
3861 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3862
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3863
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3864 2177 return 0;
3865
3866 12102 power = game->get_hero_dmgmult();
3867 12571 }
3868
3869 fsparkle:
3870
3871 [[fallthrough]];
3872 default:
3873 // Work out the defenses!
3874 {
3875 98473 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3876
3877
2/2
✓ Branch 0 taken 26468 times.
✓ Branch 1 taken 72005 times.
98473 if(def >= 0)
3878 26468 return def;
3879
2/2
✓ Branch 0 taken 71545 times.
✓ Branch 1 taken 460 times.
72005 else if(def == -2)
3880 {
3881 460 ret = 0;
3882 460 }
3883 }
3884
3885
2/2
✓ Branch 0 taken 72003 times.
✓ Branch 1 taken 2 times.
144010 if(!power)
3886 {
3887
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3888 2 hp-=1;
3889 else
3890 {
3891 // Don't make a long chain of 'stun' hits
3892 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3893 return 1;
3894
3895
3896 if(!switch_hooked)
3897 stunclk=160;
3898 break;
3899 }
3900 2 }
3901 72003 else hp-=power;
3902
3903 hitclock:
3904 77206 hclk=33;
3905
3906 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3907
2/2
✓ Branch 0 taken 34517 times.
✓ Branch 1 taken 42689 times.
77206 if((dir&2)==(w->dir&2))
3908 {
3909 42689 sclk=(w->dir<<8)+16;
3910 42689 }
3911 77206 }
3912
3913
5/6
✓ Branch 0 taken 73789 times.
✓ Branch 1 taken 19562 times.
✓ Branch 2 taken 21974 times.
✓ Branch 3 taken 71377 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21974 times.
93351 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3914 {
3915 21974 fading=fade_blue_poof;
3916 21974 }
3917
3918
6/6
✓ Branch 0 taken 88418 times.
✓ Branch 1 taken 4933 times.
✓ Branch 2 taken 46745 times.
✓ Branch 3 taken 41673 times.
✓ Branch 4 taken 2155 times.
✓ Branch 5 taken 44590 times.
93351 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3919 {
3920
2/2
✓ Branch 0 taken 7081 times.
✓ Branch 1 taken 7 times.
7088 if( hitsfx > 0 ) //user-set hit sound.
3921 {
3922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7081 times.
7081 if (!dying) //don't play the hit sound on death! -Z
3923 7081 sfx(hitsfx, pan(int32_t(x)));
3924 7081 }
3925 7 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3926 7088 }
3927 else //2.50.2 or earlier
3928 {
3929 86263 sfx(WAV_EHIT, pan(int32_t(x)));
3930 86263 sfx(hitsfx, pan(int32_t(x)));
3931 }
3932
2/2
✓ Branch 0 taken 93322 times.
✓ Branch 1 taken 29 times.
93351 if(family==eeGUY)
3933 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3934
3935 // Penetrating weapons
3936
4/4
✓ Branch 0 taken 91490 times.
✓ Branch 1 taken 1861 times.
✓ Branch 2 taken 84591 times.
✓ Branch 3 taken 8760 times.
93351 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3937 {
3938 8760 int32_t item=enemyHitWeapon;
3939
3940
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 7161 times.
8760 if(wpnId==wArrow)
3941 {
3942 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3943
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1599 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3944 379 return 0;
3945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
1220 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3946 //if(item<0)
3947 else
3948 1220 item=current_item_id(itype_arrow);
3949 1220 }
3950
3951 else
3952 {
3953
3954 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3955
3/6
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7143 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7161 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3956 return 0;
3957
3958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7161 times.
7161 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3959 else
3960 //if(item<0)
3961 7161 item=current_item_id(itype_sword);
3962 }
3963 8381 }
3964
3965 92972 return ret;
3966 268835 }
3967
3968 61495234 bool enemy::dont_draw()
3969 {
3970
6/6
✓ Branch 0 taken 61032448 times.
✓ Branch 1 taken 462786 times.
✓ Branch 2 taken 60961541 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 172044 times.
✓ Branch 5 taken 60860404 times.
61495234 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3971 634830 return true;
3972
3973
2/2
✓ Branch 0 taken 1371477 times.
✓ Branch 1 taken 59488927 times.
60860404 if(flags&guy_invisible)
3974 1371477 return true;
3975
3976
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59488495 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59488927 if(flags&guy_lens_only && !lensclk)
3977 return true;
3978
3979 59488927 return false;
3980 61495234 }
3981
3982 #define DRAW_NORMAL 2
3983 #define DRAW_CLOAKED 1
3984 #define DRAW_INVIS 0
3985 // base drawing function to be used by all derived classes instead of
3986 // sprite::draw()
3987 44703810 void enemy::draw(BITMAP *dest)
3988 {
3989 44703810 didScriptThisFrame = false; //Since there's no better place to put it
3990
6/6
✓ Branch 0 taken 43940405 times.
✓ Branch 1 taken 763405 times.
✓ Branch 2 taken 43857755 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 314567 times.
✓ Branch 5 taken 43625838 times.
44703810 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3991 1077972 return;
3992
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 40858173 times.
43625838 if(flags&guy_invisible)
3993 2767665 return;
3994
3995 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
3996 // be cloaked if they have "invisible displays as cloaked" checked.
3997
3998 40858173 byte canSee = DRAW_NORMAL;
3999 //Enemy specific stuff
4000
2/2
✓ Branch 0 taken 40857009 times.
✓ Branch 1 taken 1164 times.
40858173 if ( editorflags & ENEMY_FLAG1 )
4001 {
4002 1164 canSee = DRAW_INVIS;
4003
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4004
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4005 {
4006 if (game->item[dmisc13])
4007 {
4008 canSee = DRAW_NORMAL;
4009 }
4010 //else if ( lensclk && getlensid.flags SHOWINVIS )
4011 //{
4012 //
4013 //}
4014 //else
4015 //{
4016 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4017 // //otherwisem invisible
4018 //}
4019 }
4020 1164 }
4021 //Room specific
4022
2/2
✓ Branch 0 taken 38686974 times.
✓ Branch 1 taken 2171199 times.
40858173 if (tmpscr->flags3&fINVISROOM)
4023 {
4024
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4026 2171199 }
4027 //Lens check
4028
2/2
✓ Branch 0 taken 27345 times.
✓ Branch 1 taken 40830828 times.
40858173 if (lensclk)
4029 {
4030
2/2
✓ Branch 0 taken 26913 times.
✓ Branch 1 taken 432 times.
27345 if(flags&guy_lens_only)
4031 {
4032
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4033 432 }
4034 27345 }
4035 else
4036 {
4037
2/2
✓ Branch 0 taken 40757412 times.
✓ Branch 1 taken 73416 times.
40830828 if(flags&guy_lens_only)
4038 73416 canSee = DRAW_INVIS;
4039 }
4040
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40783593 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40858173 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4041
3/4
✓ Branch 0 taken 40557589 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40557589 times.
✗ Branch 3 not taken.
40858173 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4042
4043
2/2
✓ Branch 0 taken 40783593 times.
✓ Branch 1 taken 74580 times.
40858173 if (canSee == DRAW_INVIS)
4044 74580 return;
4045
4046
4/4
✓ Branch 0 taken 40781287 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40781280 times.
40783593 if(fallclk||drownclk)
4047 {
4048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 if (canSee == DRAW_CLOAKED)
4049 {
4050 sprite::drawcloaked(dest);
4051 }
4052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 else if (canSee == DRAW_NORMAL)
4053 {
4054 2313 sprite::draw(dest);
4055 2313 }
4056 2313 return;
4057 }
4058 40781280 int32_t cshold=cs;
4059
4060
2/2
✓ Branch 0 taken 901687 times.
✓ Branch 1 taken 39879593 times.
40781280 if(dying)
4061 {
4062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901687 times.
901687 if(clk2>=19)
4063 {
4064 if(!(clk2&2))
4065 {
4066 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4067 if (canSee == DRAW_CLOAKED)
4068 {
4069 sprite::drawcloaked(dest);
4070 }
4071 else if (canSee == DRAW_NORMAL)
4072 {
4073 sprite::draw(dest);
4074 }
4075 }
4076 return;
4077 }
4078
4079 901687 flip = 0;
4080 901687 tile = wpnsbuf[spr_death].tile;
4081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901687 times.
901687 if ( do_animation )
4082 {
4083 901687 int32_t offs = 0;
4084
2/2
✓ Branch 0 taken 850820 times.
✓ Branch 1 taken 50867 times.
901687 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4085 {
4086
2/2
✓ Branch 0 taken 49251 times.
✓ Branch 1 taken 1616 times.
50867 if(clk2 > 2)
4087 {
4088 1616 spr_death_anim_clk=0;
4089 1616 clk2=1;
4090
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1602 times.
1616 if(hp > -1000)
4091 1602 death_sfx();
4092 1616 }
4093
4/4
✓ Branch 0 taken 38168 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 37766 times.
50867 if(clk2==1 && spr_death_anim_clk>-1)
4094 {
4095 37766 ++clk2;
4096
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
37766 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4097
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37745 times.
37766 spr_death_anim_frm *= zc_max(1,txsz);
4098 37766 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4099
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37690 times.
37766 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4100
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 37764 times.
✓ Branch 4 taken 36168 times.
✓ Branch 5 taken 1598 times.
37766 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4101 {
4102 1598 spr_death_anim_clk=-1;
4103 1598 clk2=1;
4104 1598 }
4105 37766 }
4106 50867 tile += spr_death_anim_frm;
4107 50867 }
4108
2/2
✓ Branch 0 taken 313513 times.
✓ Branch 1 taken 537307 times.
850820 else if(BSZ)
4109 {
4110
2/2
✓ Branch 0 taken 246522 times.
✓ Branch 1 taken 66991 times.
313513 offs = zc_min((15-clk2)/3,4);
4111 313513 }
4112
4/4
✓ Branch 0 taken 358283 times.
✓ Branch 1 taken 179024 times.
✓ Branch 2 taken 179013 times.
✓ Branch 3 taken 179270 times.
537307 else if(clk2>6 && clk2<=12)
4113 {
4114 179270 offs = 1;
4115 179270 }
4116
4117
2/2
✓ Branch 0 taken 455054 times.
✓ Branch 1 taken 446633 times.
901687 if(offs)
4118 {
4119
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 446183 times.
446633 offs *= zc_max(1,txsz);
4120 446633 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4121
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 446195 times.
446633 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4122 446633 }
4123 901687 tile += offs;
4124 901687 }
4125
4126
6/6
✓ Branch 0 taken 850820 times.
✓ Branch 1 taken 50867 times.
✓ Branch 2 taken 537307 times.
✓ Branch 3 taken 313513 times.
✓ Branch 4 taken 189344 times.
✓ Branch 5 taken 347963 times.
901687 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4127 553724 cs = wpnsbuf[spr_death].csets&15;
4128 else
4129 347963 cs = (((clk2+5)>>1)&3)+6;
4130 901687 }
4131
3/4
✓ Branch 0 taken 1189488 times.
✓ Branch 1 taken 38690105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1189488 times.
39879593 else if(hclk>0 && getCanFlicker())
4132 {
4133 1189488 cs = getFlashingCSet();
4134 1189488 }
4135 //draw every other frame for flickering enemies
4136
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40533249 times.
40781280 if (is_hitflickerframe(false))
4137 {
4138
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4139
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4140 {
4141 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4142 sprite_flicker_color = temp_flicker_color;
4143 sprite::draw(dest);
4144 }
4145 248031 }
4146 else
4147 {
4148
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40308087 times.
40533249 if (canSee == DRAW_CLOAKED)
4149 {
4150 225162 sprite::drawcloaked(dest);
4151 225162 }
4152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40308087 times.
40308087 else if (canSee == DRAW_NORMAL)
4153 {
4154
1/2
✓ Branch 0 taken 40308087 times.
✗ Branch 1 not taken.
40308087 if ( frozenclock < 0 )
4155 {
4156 if ( frozentile > 0 ) tile = frozentile;
4157 loadpalset(csBOSS,frozencset);
4158 }
4159 40308087 sprite::draw(dest);
4160 40308087 }
4161 }
4162 40781280 cs=cshold;
4163 44703810 }
4164
4165 //old zc bosses
4166 40752657 void enemy::drawzcboss(BITMAP *dest)
4167 {
4168 40752657 didScriptThisFrame = false; //Since there's no better place to put it
4169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40752657 times.
40752657 if(dont_draw())
4170 return;
4171
4172 40752657 int32_t cshold=cs;
4173
4174
2/2
✓ Branch 0 taken 781746 times.
✓ Branch 1 taken 39970911 times.
40752657 if(dying)
4175 {
4176
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 777786 times.
781746 if(clk2>=19)
4177 {
4178
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4179 1980 sprite::drawzcboss(dest);
4180
4181 3960 return;
4182 }
4183
4184 777786 flip = 0;
4185 777786 tile = wpnsbuf[spr_death].tile;
4186
4187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777786 times.
777786 if ( do_animation )
4188 {
4189
2/2
✓ Branch 0 taken 773270 times.
✓ Branch 1 taken 4516 times.
777786 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4190 {
4191
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4192 {
4193 6 spr_death_anim_clk=0;
4194 6 clk2=1;
4195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4196 6 death_sfx();
4197 6 }
4198
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4199 {
4200 76 ++clk2;
4201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4203 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4205
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4206 {
4207 2 spr_death_anim_clk=-1;
4208 2 clk2=1;
4209 2 }
4210 76 }
4211 4516 tile += spr_death_anim_frm;
4212 4516 }
4213
2/2
✓ Branch 0 taken 276492 times.
✓ Branch 1 taken 496778 times.
773270 else if(BSZ)
4214
2/2
✓ Branch 0 taken 217484 times.
✓ Branch 1 taken 59008 times.
276492 tile += zc_min((15-clk2)/3,4);
4215
4/4
✓ Branch 0 taken 331149 times.
✓ Branch 1 taken 165629 times.
✓ Branch 2 taken 165472 times.
✓ Branch 3 taken 165677 times.
496778 else if(clk2>6 && clk2<=12)
4216 165677 ++tile;
4217 777786 }
4218
4219
6/6
✓ Branch 0 taken 773270 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496778 times.
✓ Branch 3 taken 276492 times.
✓ Branch 4 taken 184034 times.
✓ Branch 5 taken 312744 times.
777786 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4220 465042 cs = wpnsbuf[spr_death].csets&15;
4221 else
4222 312744 cs = (((clk2+5)>>1)&3)+6;
4223 777786 }
4224
2/2
✓ Branch 0 taken 38770797 times.
✓ Branch 1 taken 1200114 times.
39970911 else if(hclk>0)
4225 {
4226 1200114 cs = getFlashingCSet();
4227 1200114 }
4228
4229
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38703078 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40756240 if((tmpscr->flags3&fINVISROOM) &&
4230
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4232 7543 lensclk) && family!=eeGANON)
4233 {
4234 7543 sprite::drawcloaked(dest);
4235 7543 }
4236 else
4237 {
4238
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40717681 times.
40741154 if (is_hitflickerframe(true))
4239 {
4240
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4241
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4242 {
4243 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4244 sprite_flicker_color = temp_flicker_color;
4245 sprite::drawzcboss(dest);
4246 }
4247 23473 }
4248 else
4249 40717681 sprite::drawzcboss(dest);
4250 }
4251
4252 40748697 cs=cshold;
4253 40752657 }
4254
4255
4256 // similar to the overblock function--can do up to a 32x32 sprite
4257 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4258 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4259 {
4260 323235 int32_t thold=tile;
4261 323235 int32_t t1=tile;
4262 323235 int32_t t2=tile+20;
4263 323235 int32_t t3=tile+1;
4264 323235 int32_t t4=tile+21;
4265
4266
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4267 {
4268 case 1:
4269 enemy::drawzcboss(dest);
4270 break;
4271
4272 case 3:
4273 if(flip&2)
4274 zc_swap(t1,t2);
4275
4276 tile=t1;
4277 enemy::drawzcboss(dest);
4278 tile=t2;
4279 yofs+=16;
4280 enemy::drawzcboss(dest);
4281 yofs-=16;
4282 break;
4283
4284 case 5:
4285 t2=tile+1;
4286
4287 if(flip&1)
4288 zc_swap(t1,t2);
4289
4290 tile=t1;
4291 enemy::drawzcboss(dest);
4292 tile=t2;
4293 xofs+=16;
4294 enemy::drawzcboss(dest);
4295 xofs-=16;
4296 break;
4297
4298 case 15:
4299
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4300 {
4301 6756 zc_swap(t1,t3);
4302 6756 zc_swap(t2,t4);
4303 6756 }
4304
4305
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4306 {
4307 zc_swap(t1,t2);
4308 zc_swap(t3,t4);
4309 }
4310
4311 323235 tile=t1;
4312 323235 enemy::drawzcboss(dest);
4313 323235 tile=t2;
4314 323235 yofs+=16;
4315 323235 enemy::drawzcboss(dest);
4316 323235 yofs-=16;
4317 323235 tile=t3;
4318 323235 xofs+=16;
4319 323235 enemy::drawzcboss(dest);
4320 323235 tile=t4;
4321 323235 yofs+=16;
4322 323235 enemy::drawzcboss(dest);
4323 323235 xofs-=16;
4324 323235 yofs-=16;
4325 323235 break;
4326 }
4327
4328 323235 tile=thold;
4329 323235 }
4330
4331 20178752 void enemy::drawshadow(BITMAP *dest, bool translucent)
4332 {
4333
4/4
✓ Branch 0 taken 18172445 times.
✓ Branch 1 taken 2006307 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 17766356 times.
20178752 if(dont_draw() || isSideViewGravity())
4334 {
4335 2412396 return;
4336 }
4337
4338
2/2
✓ Branch 0 taken 326866 times.
✓ Branch 1 taken 17439490 times.
17766356 if(dying)
4339 {
4340 326866 return;
4341 }
4342
4343
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15721241 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17092480 times.
17439490 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4344 17439490 (darkroom))
4345 {
4346 347010 return;
4347 }
4348 else
4349 {
4350
4/4
✓ Branch 0 taken 16518574 times.
✓ Branch 1 taken 573906 times.
✓ Branch 2 taken 16471201 times.
✓ Branch 3 taken 47373 times.
17092480 if(enemycanfall(id, false) && shadowtile == 0)
4351 47373 shadowtile = wpnsbuf[spr_shadow].tile;
4352
4353
5/6
✓ Branch 0 taken 16154116 times.
✓ Branch 1 taken 938364 times.
✓ Branch 2 taken 16154116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15580210 times.
✓ Branch 5 taken 573906 times.
17092480 if(z>0 || fakez>0 || !enemycanfall(id, false))
4354 {
4355
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1511995 times.
1512270 if(!shadow_overpit(this))
4356 1511995 sprite::drawshadow(dest,translucent);
4357 1512270 }
4358 }
4359 20178752 }
4360
4361 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4362 {
4363 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4364
4365
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4366 {
4367 129181 xofs-=mx;
4368 129181 yofs-=my;
4369 129181 enemy::draw(sub);
4370 129181 xofs+=mx;
4371 129181 yofs+=my;
4372 129181 destroy_bitmap(sub);
4373 129181 }
4374 else
4375 enemy::draw(dest);
4376 129181 }
4377
4378 9 void enemy::init_size_flags()
4379 {
4380
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4381
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4382
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4383
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4384
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4385
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4386
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4387
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4388
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
4389 {
4390 yofs = (int32_t)d->yofs;
4391 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4392 }
4393
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4394 9 }
4395
4396 // override hit detection to check for invicibility, stunned, etc
4397 112151935 bool enemy::hit()
4398 {
4399
4/4
✓ Branch 0 taken 110828636 times.
✓ Branch 1 taken 1323299 times.
✓ Branch 2 taken 109033740 times.
✓ Branch 3 taken 1794896 times.
112151935 if(dying || hclk>0) return false;
4400 109033740 return sprite::hit();
4401 112151935 }
4402 730351 bool enemy::hit(sprite *s)
4403 {
4404
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4405 713374 return sprite::hit(s);
4406 730351 }
4407
4408 44501745 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4409 {
4410
2/2
✓ Branch 0 taken 3919072 times.
✓ Branch 1 taken 40582673 times.
44501745 if(!hit()) return false;
4411 40582673 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4412 44501745 }
4413 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4414 {
4415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4416 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4417 78011 }
4418
4419 11132898 bool enemy::hit(weapon *w)
4420 {
4421
2/2
✓ Branch 0 taken 1172363 times.
✓ Branch 1 taken 9960535 times.
11132898 if(!hit()) return false;
4422
4423
2/2
✓ Branch 0 taken 6645972 times.
✓ Branch 1 taken 3314563 times.
9960535 if (replay_version_check(0, 14))
4424 {
4425
4/6
✓ Branch 0 taken 6421665 times.
✓ Branch 1 taken 224307 times.
✓ Branch 2 taken 6421665 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6421665 times.
✗ Branch 5 not taken.
6645972 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4426 224307 return false;
4427 6421665 return sprite::hit(w);
4428 }
4429 3314563 return w->hit(this);
4430 11132898 }
4431
4432 9456450 bool enemy::can_pitfall(bool checkspawning)
4433 {
4434
4/4
✓ Branch 0 taken 9436662 times.
✓ Branch 1 taken 19788 times.
✓ Branch 2 taken 9426007 times.
✓ Branch 3 taken 30443 times.
9456450 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4435
2/2
✓ Branch 0 taken 9408347 times.
✓ Branch 1 taken 17660 times.
9426007 switch(guysbuf[id&0xFFF].family)
4436 {
4437 case eeAQUA:
4438 case eeDIG:
4439 case eeDONGO:
4440 case eeFAIRY:
4441 case eeGANON:
4442 case eeGHOMA:
4443 case eeGLEEOK:
4444 case eeGUY:
4445 case eeLANM:
4446 case eeMANHAN:
4447 case eeMOLD:
4448 case eeNONE:
4449 case eePATRA:
4450 case eeZORA:
4451 17660 return false; //Disallowed types
4452 default:
4453 9408347 return true;
4454 }
4455 9456450 }
4456 //Handle death
4457 37824270 void enemy::try_death(bool force_kill)
4458 {
4459
8/8
✓ Branch 0 taken 37769243 times.
✓ Branch 1 taken 55027 times.
✓ Branch 2 taken 37769232 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43498 times.
✓ Branch 5 taken 37725734 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43497 times.
37824270 if(!dying && (force_kill || (hp<=0 && !immortal)))
4460 {
4461 43508 std::vector<int32_t> &ev = FFCore.eventData;
4462 43508 ev.clear();
4463 43508 ev.push_back(10000);
4464 43508 ev.push_back(getUID());
4465
4466 43508 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4467 43508 bool isSaved = !ev[0];
4468 43508 ev.clear();
4469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43508 times.
43508 if(isSaved) return;
4470
4471
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 43460 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 42 times.
43508 if(itemguy && (hasitem&2)!=0)
4472 {
4473
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 42 times.
89 for(int32_t i=0; i<items.Count(); i++)
4474 {
4475
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 42 times.
47 if(((item*)items.spr(i))->pickup&ipENEMY)
4476 {
4477
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1 times.
42 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4478 {
4479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4480 {
4481 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4482 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4483 }
4484 else
4485 {
4486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(extend >= 3)
4487 {
4488 items.spr(i)->x = x+(txsz-1)*8;
4489 items.spr(i)->y = y-2+(tysz-1)*8;
4490 }
4491 else
4492 {
4493 1 items.spr(i)->x = x;
4494 1 items.spr(i)->y = y - 2;
4495 }
4496 }
4497 1 items.spr(i)->z = z;
4498 1 items.spr(i)->fakez = fakez;
4499 1 }
4500 else
4501 {
4502 41 items.spr(i)->x = x;
4503 41 items.spr(i)->y = y - 2;
4504 }
4505 42 }
4506 47 }
4507 42 }
4508
4509 43508 dying=true;
4510
4511
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43476 times.
43508 if(fading==fade_flash_die)
4512 32 clk2=19+18*4;
4513 else
4514 {
4515 43476 clk2 = BSZ ? 15 : 19;
4516
4517
2/2
✓ Branch 0 taken 21056 times.
✓ Branch 1 taken 22420 times.
43476 if(fading!=fade_blue_poof)
4518 22420 fading=0;
4519 }
4520
4521
2/2
✓ Branch 0 taken 43460 times.
✓ Branch 1 taken 48 times.
43508 if(itemguy)
4522 {
4523 48 hasitem&=~2;
4524 48 item_set=0;
4525 48 }
4526
4527
6/6
✓ Branch 0 taken 42454 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33769 times.
✓ Branch 3 taken 8685 times.
✓ Branch 4 taken 1413 times.
✓ Branch 5 taken 32356 times.
43508 if(currscr<128 && count_enemy && !script_spawned)
4528 32356 game->guys[(currmap<<7)+currscr]-=1;
4529 43508 }
4530 37824270 }
4531
4532 // --==**==--
4533
4534 // Movement routines that can be used by derived classes as needed
4535
4536 // --==**==--
4537
4538 555845 void enemy::fix_coords(bool bound)
4539 {
4540
1/2
✓ Branch 0 taken 555845 times.
✗ Branch 1 not taken.
555845 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555845 times.
555845 if(moveflags & move_ignore_screenedge) bound = false;
4542
4543
4544
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474165 times.
555845 if(bound)
4545 {
4546
1/2
✓ Branch 0 taken 474165 times.
✗ Branch 1 not taken.
474165 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4547 {
4548
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474165 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4549
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474165 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4550 474165 }
4551 else
4552 {
4553 x=vbound(x, 0_zf,240_zf);
4554 y=vbound(y, 0_zf,160_zf);
4555 }
4556 474165 }
4557
4558
6/10
✓ Branch 0 taken 554831 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 555845 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 555845 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 555845 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 555845 times.
555845 if(!OUTOFBOUNDS)
4559 {
4560 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4561
4562 if(isSideViewGravity())
4563 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4564 else
4565 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4566 */
4567 555845 do_fix(x, 16, true);
4568
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 554831 times.
555845 if(isSideViewGravity())
4569 1014 do_fix(y,8,true);
4570 554831 else do_fix(y,16,true);
4571 555845 }
4572 555845 }
4573 9156 bool enemy::cannotpenetrate()
4574 {
4575
4/4
✓ Branch 0 taken 8975 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8937 times.
9156 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4576 }
4577
4578 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4579 {
4580 bool ok;
4581 562 int32_t dx = 0, dy = 0;
4582 562 int32_t sv = 8;
4583
4584 //Why is this here??? Why is it needed???
4585 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4586
4587
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4588 {
4589 case 8:
4590 case up:
4591
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4592 return false;
4593
4594 69 dy = dy1-s;
4595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4597 69 break;
4598
4599 case 12:
4600 case down:
4601
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4602 return false;
4603
4604 51 dy = dy2+s;
4605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4606 51 break;
4607
4608 case 14:
4609 case left:
4610 47 dx = dx1-s;
4611 47 sv = ((isSideViewGravity())?7:8);
4612
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4613
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4614 47 break;
4615
4616 case 10:
4617 case right:
4618 85 dx = dx2+s;
4619 85 sv = ((isSideViewGravity())?7:8);
4620
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4621 85 break;
4622
4623 case 9:
4624 case r_up:
4625 94 dx = dx2+s;
4626 94 dy = dy1-s;
4627
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4629 94 break;
4630
4631 case 11:
4632 case r_down:
4633 78 dx = dx2+s;
4634 78 dx = dy2+s;
4635
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4637 78 break;
4638
4639 case 13:
4640 case l_down:
4641 57 dx = dx1-s;
4642 57 dy = dy2+s;
4643
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4645 57 break;
4646
4647 case 15:
4648 case l_up:
4649 81 dx = dx1-s;
4650 81 dy = dy1-s;
4651
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4653 81 break;
4654
4655 default:
4656 db=99;
4657 return true;
4658 }
4659
4660 562 return ok;
4661 562 }
4662
4663
4664
4665
4666 // returns true if next step is ok, false if there is something there
4667 7325285 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4668 {
4669 7325285 bool ok = false; //initialise the var, son't just declare it
4670 7325285 int32_t dx = 0, dy = 0;
4671 7325285 int32_t sv = 8;
4672 7325285 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4673 //Why is this here??? Why is it needed???
4674 7325285 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325285 times.
7325285 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325285 times.
7325285 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4677
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325272 times.
7325285 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4678
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325272 times.
7325285 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4679 7325285 bool offgrid = OFFGRID_ENEMY;
4680
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7317994 times.
7325285 if(!offgrid)
4681 {
4682 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4683
1/2
✓ Branch 0 taken 7317994 times.
✗ Branch 1 not taken.
7317994 if(usehei<16)usehei=16;
4684
1/2
✓ Branch 0 taken 7317994 times.
✗ Branch 1 not taken.
7317994 if(usewid<16)usewid=16;
4685 7317994 }
4686
9/9
✓ Branch 0 taken 1327891 times.
✓ Branch 1 taken 1102926 times.
✓ Branch 2 taken 1222014 times.
✓ Branch 3 taken 1212951 times.
✓ Branch 4 taken 536645 times.
✓ Branch 5 taken 638123 times.
✓ Branch 6 taken 600184 times.
✓ Branch 7 taken 564898 times.
✓ Branch 8 taken 119653 times.
7325285 switch(ndir) //need to check every 8 pixels between two points
4687 {
4688 case 8:
4689 case up:
4690 {
4691
4/4
✓ Branch 0 taken 150637 times.
✓ Branch 1 taken 1177254 times.
✓ Branch 2 taken 150047 times.
✓ Branch 3 taken 590 times.
1327891 if(enemycanfall(id) && isSideViewGravity())
4692 590 return false;
4693
4694 1327301 dy = dy1-s;
4695
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1326821 times.
1327301 special = (special==spw_clipbottomright)?spw_none:special;
4696 1327301 tries = usewid/(offgrid ? 8 : 16);
4697 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4698
2/2
✓ Branch 0 taken 1127193 times.
✓ Branch 1 taken 1327951 times.
2455144 for ( ; tries > 0; --tries )
4699 {
4700
2/2
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 1130463 times.
1327951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4701 1327951 try_x += (offgrid ? 8 : 16);
4702
2/2
✓ Branch 0 taken 1127843 times.
✓ Branch 1 taken 200108 times.
1327951 if (!ok) break;
4703 1127843 }
4704
2/2
✓ Branch 0 taken 1127193 times.
✓ Branch 1 taken 200108 times.
1327301 if(!ok) break;
4705
1/2
✓ Branch 0 taken 1127193 times.
✗ Branch 1 not taken.
1127193 if((usewid%16)>0) //Uneven width
4706 {
4707 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4708 }
4709 1127193 break;
4710 }
4711 case 12:
4712 case down:
4713 {
4714
4/4
✓ Branch 0 taken 180556 times.
✓ Branch 1 taken 922370 times.
✓ Branch 2 taken 179868 times.
✓ Branch 3 taken 688 times.
1102926 if(enemycanfall(id) && isSideViewGravity())
4715 688 return false;
4716
4717 1102238 dy = dy2+s;
4718 1102238 tries = usewid/(offgrid ? 8 : 16);
4719 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4720
2/2
✓ Branch 0 taken 896247 times.
✓ Branch 1 taken 1103022 times.
1999269 for ( ; tries > 0; --tries )
4721 {
4722
3/4
✓ Branch 0 taken 205243 times.
✓ Branch 1 taken 897779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 897779 times.
1103022 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4723 1103022 try_x += (offgrid ? 8 : 16);
4724
2/2
✓ Branch 0 taken 897031 times.
✓ Branch 1 taken 205991 times.
1103022 if (!ok) break;
4725 897031 }
4726
2/2
✓ Branch 0 taken 896247 times.
✓ Branch 1 taken 205991 times.
1102238 if(!ok) break;
4727
1/2
✓ Branch 0 taken 896247 times.
✗ Branch 1 not taken.
896247 if((usewid%16)>0) //Uneven width
4728 {
4729 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4730 }
4731 896247 break;
4732 }
4733 case 14:
4734 case left:
4735 {
4736 1222014 dx = dx1-s;
4737 1222014 sv = ((isSideViewGravity())?7:0);
4738
4/4
✓ Branch 0 taken 1221391 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1219623 times.
1222014 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4739 1222014 tries = usehei/(offgrid ? 8 : 16);
4740 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4741
2/2
✓ Branch 0 taken 1023089 times.
✓ Branch 1 taken 1222931 times.
2246020 for ( ; tries > 0; --tries )
4742 {
4743
2/2
✓ Branch 0 taken 197742 times.
✓ Branch 1 taken 1025189 times.
1222931 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4744 1222931 try_y += (offgrid ? 8 : 16);
4745
2/2
✓ Branch 0 taken 1024006 times.
✓ Branch 1 taken 198925 times.
1222931 if (!ok) break;
4746 1024006 }
4747
2/2
✓ Branch 0 taken 1023089 times.
✓ Branch 1 taken 198925 times.
1222014 if(!ok) break;
4748
1/2
✓ Branch 0 taken 1023089 times.
✗ Branch 1 not taken.
1023089 if((usehei%16)>0) //Uneven height
4749 {
4750 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4751 }
4752 1023089 break;
4753 }
4754 case 10:
4755 case right:
4756 {
4757 1212951 dx = dx2+s;
4758 1212951 sv = ((isSideViewGravity())?7:0);
4759 1212951 tries = usehei/(offgrid ? 8 : 16);
4760 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4761
2/2
✓ Branch 0 taken 1024852 times.
✓ Branch 1 taken 1213845 times.
2238697 for ( ; tries > 0; --tries )
4762 {
4763
3/4
✓ Branch 0 taken 186746 times.
✓ Branch 1 taken 1027099 times.
✓ Branch 2 taken 1027099 times.
✗ Branch 3 not taken.
1213845 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4764 1213845 try_y += (offgrid ? 8 : 16);
4765
2/2
✓ Branch 0 taken 1025746 times.
✓ Branch 1 taken 188099 times.
1213845 if (!ok) break;
4766 1025746 }
4767
2/2
✓ Branch 0 taken 1024852 times.
✓ Branch 1 taken 188099 times.
1212951 if(!ok) break;
4768
1/2
✓ Branch 0 taken 1024852 times.
✗ Branch 1 not taken.
1024852 if((usehei%16)>0) //Uneven height
4769 {
4770 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4771 }
4772 1024852 break;
4773 }
4774 case 9:
4775 case r_up:
4776 {
4777 536645 dx = dx2+s;
4778 536645 dy = dy1-s;
4779 536645 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4780 536645 sv = ((isSideViewGravity())?7:0);
4781
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_x > 0; --tries_x )
4782 {
4783 536645 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4784 536645 try_y = 0;
4785
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_y > 0; --tries_y )
4786 {
4787
4/4
✓ Branch 0 taken 528401 times.
✓ Branch 1 taken 8244 times.
✓ Branch 2 taken 522980 times.
✓ Branch 3 taken 5421 times.
1059625 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4788
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 520588 times.
522980 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4789 536645 try_y += (offgrid ? 8 : 16);
4790
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4791 519643 }
4792
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519643 times.
519643 if((usehei%16)>0) //Uneven height
4794 {
4795 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4796 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4797 }
4798 519643 try_x += (offgrid ? 8 : 16);
4799 519643 }
4800
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if(!ok) break;
4801
1/2
✓ Branch 0 taken 519643 times.
✗ Branch 1 not taken.
519643 if((usewid%16)>0) //Uneven width
4802 {
4803 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4804 try_y = 0;
4805 for ( ; tries_y > 0; --tries_y )
4806 {
4807 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4808 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4809 try_y += (offgrid ? 8 : 16);
4810 if (!ok) break;
4811 }
4812 if (!ok) break;
4813 if((usehei%16)>0) //Uneven height
4814 {
4815 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4816 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4817 }
4818 }
4819 519643 break;
4820 }
4821 case 11:
4822 case r_down:
4823 {
4824 638123 dx = dx2+s;
4825 638123 dx = dy2+s;
4826 638123 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4827 //sv = ((isSideViewGravity())?7:0);
4828
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_x > 0; --tries_x )
4829 {
4830 638123 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4831 638123 try_y = 0;
4832
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_y > 0; --tries_y )
4833 {
4834
4/4
✓ Branch 0 taken 636612 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 623840 times.
✓ Branch 3 taken 12772 times.
1261963 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4835
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 623734 times.
623840 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4836 638123 try_y += (offgrid ? 8 : 16);
4837
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4838 622773 }
4839
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 622773 times.
622773 if((usehei%16)>0) //Uneven height
4841 {
4842 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4843 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4844 }
4845 622773 try_x += (offgrid ? 8 : 16);
4846 622773 }
4847
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if(!ok) break;
4848
1/2
✓ Branch 0 taken 622773 times.
✗ Branch 1 not taken.
622773 if((usewid%16)>0) //Uneven width
4849 {
4850 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4851 try_y = 0;
4852 for ( ; tries_y > 0; --tries_y )
4853 {
4854 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4855 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4856 try_y += (offgrid ? 8 : 16);
4857 if (!ok) break;
4858 }
4859 if (!ok) break;
4860 if((usehei%16)>0) //Uneven height
4861 {
4862 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4863 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4864 }
4865 }
4866 622773 break;
4867 }
4868 case 13:
4869 case l_down:
4870 {
4871 600184 dx = dx1-s;
4872 600184 dy = dy2+s;
4873 600184 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4874 //sv = ((isSideViewGravity())?7:0);
4875
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_x > 0; --tries_x )
4876 {
4877 600184 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4878 600184 try_y = 0;
4879
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_y > 0; --tries_y )
4880 {
4881
4/4
✓ Branch 0 taken 588277 times.
✓ Branch 1 taken 11907 times.
✓ Branch 2 taken 584012 times.
✓ Branch 3 taken 4265 times.
1184196 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4882
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 583444 times.
584012 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4883 600184 try_y += (offgrid ? 8 : 16);
4884
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4885 583146 }
4886
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583146 times.
583146 if((usehei%16)>0) //Uneven height
4888 {
4889 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4890 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4891 }
4892 583146 try_x += (offgrid ? 8 : 16);
4893 583146 }
4894
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if(!ok) break;
4895
1/2
✓ Branch 0 taken 583146 times.
✗ Branch 1 not taken.
583146 if((usewid%16)>0) //Uneven width
4896 {
4897 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4898 try_y = 0;
4899 for ( ; tries_y > 0; --tries_y )
4900 {
4901 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4902 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4903 try_y += (offgrid ? 8 : 16);
4904 if (!ok) break;
4905 }
4906 if (!ok) break;
4907 if((usehei%16)>0) //Uneven height
4908 {
4909 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4910 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4911 }
4912 }
4913 583146 break;
4914 }
4915 case 15:
4916 case l_up:
4917 {
4918 564898 dx = dx1-s;
4919 564898 dy = dy1-s;
4920 564898 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4921 564898 sv = ((isSideViewGravity())?7:0);
4922
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_x > 0; --tries_x )
4923 {
4924 564898 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4925 564898 try_y = 0;
4926
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_y > 0; --tries_y )
4927 {
4928
4/4
✓ Branch 0 taken 556265 times.
✓ Branch 1 taken 8633 times.
✓ Branch 2 taken 552308 times.
✓ Branch 3 taken 3957 times.
1117206 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4929
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 549869 times.
552308 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4930 564898 try_y += (offgrid ? 8 : 16);
4931
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4932 549004 }
4933
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549004 times.
549004 if((usehei%16)>0) //Uneven height
4935 {
4936 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4937 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4938 }
4939 549004 try_x += (offgrid ? 8 : 16);
4940 549004 }
4941
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if(!ok) break;
4942
1/2
✓ Branch 0 taken 549004 times.
✗ Branch 1 not taken.
549004 if((usewid%16)>0) //Uneven width
4943 {
4944 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4945 try_y = 0;
4946 for ( ; tries_y > 0; --tries_y )
4947 {
4948 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4949 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4950 try_y += (offgrid ? 8 : 16);
4951 if (!ok) break;
4952 }
4953 if (!ok) break;
4954 if((usehei%16)>0) //Uneven height
4955 {
4956 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4957 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4958 }
4959 }
4960 549004 break;
4961 }
4962 default:
4963 119653 db=99;
4964 119653 return true;
4965 }
4966 //Z_eventlog("\n");
4967 7204354 return ok;
4968 7325285 }
4969
4970
4971 4624298 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4972 {
4973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624298 times.
4624298 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624298 times.
4624298 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4975
1/2
✓ Branch 0 taken 4624298 times.
✗ Branch 1 not taken.
4624298 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4976
1/2
✓ Branch 0 taken 4624298 times.
✗ Branch 1 not taken.
4624298 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4977 4624298 --usewid;
4978 4624298 --usehei;
4979 4624298 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4980 }
4981
4982 1243207 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4983 {
4984 1243207 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
4985
4986
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1236388 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1243207 if(special==spw_clipright&&ndir==right)
4987 {
4988 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
4989 1798 }
4990
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243202 times.
1243207 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4991
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243202 times.
1243207 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4992
1/2
✓ Branch 0 taken 1243207 times.
✗ Branch 1 not taken.
1243207 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4993
1/2
✓ Branch 0 taken 1243207 times.
✗ Branch 1 not taken.
1243207 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4994 1243207 --usewid;
4995 1243207 --usehei;
4996
2/2
✓ Branch 0 taken 716881 times.
✓ Branch 1 taken 526326 times.
1243207 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
4997 }
4998
4999 136202 bool enemy::canmove(int32_t ndir, bool kb)
5000 {
5001 136202 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5002 }
5003
5004 // 8-directional
5005 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5006 {
5007 562 int32_t ndir=0;
5008
5009 // can move straight, check if it wants to turn
5010
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5011 {
5012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5013 {
5014 int32_t w = Lwpns.idFirst(wBait);
5015
5016 if(w>=0)
5017 {
5018 int32_t bx = Lwpns.spr(w)->x;
5019 int32_t by = Lwpns.spr(w)->y;
5020
5021 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5022
5023 if(abs(int32_t(y)-by)>14)
5024 {
5025 if(ndir>0) // Already left or right
5026 {
5027 // Making the diagonal directions
5028 ndir += (by<y) ? 2 : 4;
5029 }
5030 else
5031 {
5032 ndir = (by<y) ? up : down;
5033 }
5034 }
5035
5036 if(canmove(ndir,special,false))
5037 {
5038 dir=ndir;
5039 return;
5040 }
5041 }
5042 }
5043
5044 // Homing added.
5045
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5046 {
5047 ndir = lined_up(8,true);
5048
5049 if(ndir>=0 && canmove(ndir,special,false))
5050 {
5051 dir=ndir;
5052 }
5053
5054 return;
5055 }
5056
5057 549 int32_t r=zc_oldrand();
5058
5059
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5060 {
5061 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5062 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5063
5064
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5065 525 dir=ndir;
5066
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5067 19 dir=ndir2;
5068
5069
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5070 // due to numerous lost fractional components. -L
5071 {
5072 x.doFloor();
5073 y.doFloor();
5074 }
5075 549 }
5076
5077 549 return;
5078 }
5079
5080 // can't move straight, must turn
5081 13 int32_t i=0;
5082
5083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5084 {
5085 20 ndir=(zc_oldrand()&7)+8;
5086
5087
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5088 13 break;
5089 7 }
5090
5091
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5092 {
5093 for(ndir=8; ndir<16; ndir++)
5094 {
5095 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5096 goto ok;
5097 }
5098
5099 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5100 }
5101
5102 ok:
5103 13 dir=ndir;
5104 13 x.doFloor();
5105 13 y.doFloor();
5106 562 }
5107
5108 577113 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5109 {
5110 577113 int32_t ndir=0;
5111
5112 // can move straight, check if it wants to turn
5113
2/2
✓ Branch 0 taken 544558 times.
✓ Branch 1 taken 32555 times.
577113 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5114 {
5115
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 544351 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
544558 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5116 {
5117 101 int32_t i = Lwpns.idFirst(wBait);
5118
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5119 {
5120 weapon *w = (weapon*)Lwpns.spr(i);
5121 if (get_qr(qr_FIND_CLOSEST_BAIT))
5122 {
5123 int32_t currentrange;
5124 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5125 else currentrange = -1;
5126 int curid = i;
5127 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5128 for(; i<Lwpns.Count(); ++i)
5129 {
5130 weapon *lw = (weapon*)Lwpns.spr(i);
5131 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5132 {
5133 currentrange = distance(x, y, lw->x, lw->y);
5134 curid = i;
5135 }
5136 }
5137 i = curid;
5138 if (currentrange == -1) i = -1;
5139 }
5140 else
5141 {
5142 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5143 }
5144 if(i>=0)
5145 {
5146 int32_t bx = Lwpns.spr(i)->x;
5147 int32_t by = Lwpns.spr(i)->y;
5148
5149 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5150
5151 if(abs(int32_t(y)-by)>14)
5152 {
5153 if(ndir>0) // Already left or right
5154 {
5155 // Making the diagonal directions
5156 ndir += (by<y) ? 2 : 4;
5157 }
5158 else
5159 {
5160 ndir = (by<y) ? up : down;
5161 }
5162 }
5163 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5164 if(canmove(ndir,special,false))
5165 {
5166 dir=ndir;
5167 return;
5168 }
5169 }
5170 }
5171 101 }
5172
5173 // Homing added.
5174
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 514932 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
544558 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5175 {
5176 14216 ndir = lined_up(8,true);
5177
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5178
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5179 {
5180 5852 dir=ndir;
5181 5852 }
5182
5183 14216 return;
5184 }
5185
5186 530342 int32_t r=zc_oldrand();
5187
5188
4/4
✓ Branch 0 taken 338430 times.
✓ Branch 1 taken 191912 times.
✓ Branch 2 taken 178921 times.
✓ Branch 3 taken 159509 times.
530342 if(newrate>0 && !(r%newrate))
5189 {
5190 159509 ndir = ((dir+((r&64)?-1:1))&7)+8;
5191 159509 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5192
5193
2/2
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
159509 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5194 153722 dir=ndir;
5195
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4930 times.
5787 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5196 4930 dir=ndir2;
5197
5198
4/4
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
✓ Branch 2 taken 146396 times.
✓ Branch 3 taken 7326 times.
159509 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5199 // due to numerous lost fractional components. -L
5200 {
5201 7326 x.doFloor();
5202 7326 y.doFloor();
5203 7326 }
5204 159509 }
5205
5206 530342 return;
5207 }
5208
5209 // can't move straight, must turn
5210 32555 int32_t i=0;
5211
5212
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 60993 times.
61063 for(; i<32; i++) // Try random dir
5213 {
5214 60993 ndir=(zc_oldrand()&7)+8;
5215
5216
2/2
✓ Branch 0 taken 28508 times.
✓ Branch 1 taken 32485 times.
60993 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5217 32485 break;
5218 28508 }
5219
5220
2/2
✓ Branch 0 taken 32485 times.
✓ Branch 1 taken 70 times.
32608 if(i==32)
5221 {
5222
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5223 {
5224
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5225 17 goto ok;
5226 444 }
5227
5228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5229 53 }
5230
5231 ok:
5232 32555 dir=ndir;
5233 32555 x.doFloor();
5234 32555 y.doFloor();
5235 577113 }
5236
5237 570638 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5238 {
5239 570638 newdir_8(newrate,newhoming,special,0,-8,15,15);
5240 570638 }
5241
5242 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5243 {
5244 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5245 562 }
5246
5247 // makes the enemy slide backwards when hit
5248 // sclk: first byte is clk, second byte is dir
5249 // makes the enemy slide backwards when hit
5250 // sclk: first byte is clk, second byte is dir
5251 15625251 int32_t enemy::slide()
5252 {
5253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15625251 times.
15625251 if(script_knockback_clk!=0) //scripted knockback
5254 {
5255 sclk = 0;
5256 return 1; //scripted knockback ran
5257 }
5258
5/6
✓ Branch 0 taken 102102 times.
✓ Branch 1 taken 15523149 times.
✓ Branch 2 taken 7848 times.
✓ Branch 3 taken 94254 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7848 times.
15625251 if(sclk==0 || (hp<=0 && !immortal))
5259 15530997 return 0;
5260
5261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94254 times.
94254 if(knockbackflags & FLAG_NOSLIDE)
5262 {
5263 sclk = 0;
5264 if(!OFFGRID_ENEMY)
5265 {
5266 //Fix to grid
5267 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5268 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5269 do_fix(x, 16, true);
5270 do_fix(y, 16, true);
5271 }
5272 return 0;
5273 }
5274
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84700 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 9258 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 7105 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 296 times.
94254 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5275 {
5276 2153 sclk=0;
5277 2153 return 0;
5278 }
5279
5280 92101 --sclk;
5281
5282
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35752 times.
92101 switch(sclk>>8)
5283 {
5284 case up:
5285 {
5286
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5287 {
5288 7 sclk=0;
5289 7 return 0;
5290 }
5291
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5292
5293 10357 break;
5294 }
5295 case down:
5296 {
5297
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5298 {
5299 2 sclk=0;
5300 2 return 0;
5301 }
5302
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5303
5304 12143 break;
5305 }
5306 case left:
5307 {
5308
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5309 {
5310 13 sclk=0;
5311 13 return 0;
5312 }
5313
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5314
5315 31483 break;
5316 }
5317 case right:
5318 {
5319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35752 times.
35752 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5320 {
5321 sclk=0;
5322 return 0;
5323 }
5324
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32464 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35752 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5325 35482 break;
5326 }
5327 }
5328
5329 91250 int32_t move = knockbackSpeed;
5330
2/2
✓ Branch 0 taken 86366 times.
✓ Branch 1 taken 91250 times.
177616 while(move>0)
5331 {
5332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91250 times.
91250 int32_t thismove = zc_min(8, move);
5333 91250 move -= thismove;
5334 91250 hitdir = (sclk>>8);
5335
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35482 times.
91250 switch(sclk>>8)
5336 {
5337 case up:
5338 10357 y-=thismove;
5339 10357 break;
5340
5341 case down:
5342 12143 y+=thismove;
5343 12143 break;
5344
5345 case left:
5346 31483 x-=thismove;
5347 31483 break;
5348
5349 case right:
5350 35482 x+=thismove;
5351 35482 break;
5352 }
5353
2/2
✓ Branch 0 taken 86366 times.
✓ Branch 1 taken 4884 times.
91250 if(!canmove(sclk>>8,(zfix)0,0,true))
5354 {
5355
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2907 times.
✓ Branch 2 taken 4 times.
4884 switch(sclk>>8)
5356 {
5357 case up:
5358 case down:
5359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5360 y = 0;
5361
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5362 325 y=(int32_t(y)&0xF0)+16;
5363 else
5364 1648 y=(int32_t(y)&0xF0);
5365
5366 1973 break;
5367
5368 case left:
5369 case right:
5370
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2903 times.
2907 if(x < 0)
5371 4 x = 0;
5372
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2070 times.
2903 else if((int32_t(x)&15) > 7)
5373 833 x=(int32_t(x)&0xF0)+16;
5374 else
5375 2070 x=(int32_t(x)&0xF0);
5376
5377 2907 break;
5378 }
5379
5380 4884 sclk=0;
5381 4884 clk3=0;
5382 4884 break;
5383 }
5384 }
5385
5386
2/2
✓ Branch 0 taken 83887 times.
✓ Branch 1 taken 7363 times.
91250 if((sclk&255)==0)
5387 {
5388 //hitdir = -1;
5389 7363 sclk=0;
5390 7363 }
5391 91250 return 2;
5392 15625251 }
5393
5394 bool enemy::can_slide()
5395 {
5396 if(sclk==0 || (hp<=0 && !immortal))
5397 return false;
5398
5399 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5400 {
5401 return false;
5402 }
5403
5404 return true;
5405 }
5406
5407 bool enemy::fslide()
5408 {
5409 if(sclk==0 || (hp<=0 && !immortal))
5410 return false;
5411
5412 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5413 {
5414 sclk=0;
5415 return false;
5416 }
5417
5418 --sclk;
5419
5420 switch(sclk>>8)
5421 {
5422 case up:
5423 if(y<=16)
5424 {
5425 sclk=0;
5426 return false;
5427 }
5428
5429 break;
5430
5431 case down:
5432 if(y>=160)
5433 {
5434 sclk=0;
5435 return false;
5436 }
5437
5438 break;
5439
5440 case left:
5441 if(x<=16)
5442 {
5443 sclk=0;
5444 return false;
5445 }
5446
5447 break;
5448
5449 case right:
5450 if(x>=240)
5451 {
5452 sclk=0;
5453 return false;
5454 }
5455
5456 break;
5457 }
5458 hitdir = (sclk>>8);
5459 switch(sclk>>8)
5460 {
5461 case up:
5462 y-=4;
5463 break;
5464
5465 case down:
5466 y+=4;
5467 break;
5468
5469 case left:
5470 x-=4;
5471 break;
5472
5473 case right:
5474 x+=4;
5475 break;
5476 }
5477
5478 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5479 {
5480 switch(sclk>>8)
5481 {
5482 case up:
5483 case down:
5484 if((int32_t(y)&15) > 7)
5485 y=(int32_t(y)&0xF0)+16;
5486 else
5487 y=(int32_t(y)&0xF0);
5488
5489 break;
5490
5491 case left:
5492 case right:
5493 if((int32_t(x)&15) > 7)
5494 x=(int32_t(x)&0xF0)+16;
5495 else
5496 x=(int32_t(x)&0xF0);
5497
5498 break;
5499 }
5500
5501 sclk=0;
5502 clk3=0;
5503 }
5504
5505 if((sclk&255)==0)
5506 sclk=0;
5507
5508 return true;
5509 }
5510
5511 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5512 {
5513 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5514 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5515 bool ret = sprite::knockback(time, dir, speed);
5516 if(ret) sclk = 0; //kill engine knockback if interrupted
5517 //! Perhaps also set hitdir here, if needed for timing? -Z
5518 return ret;
5519 }
5520
5521 37824259 bool enemy::runKnockback()
5522 {
5523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37824259 times.
37824259 if((script_knockback_clk&0xFF)==0)
5524 {
5525 37824259 script_knockback_clk = 0;
5526 37824259 return false;
5527 }
5528 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5529 {
5530 return false;
5531 }
5532 int32_t move = script_knockback_speed;
5533 int32_t kb_dir = script_knockback_clk>>8;
5534 --script_knockback_clk;
5535
5536 while(move>0)
5537 {
5538 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5539 move -= thismove;
5540 hitdir = kb_dir;
5541 switch(kb_dir)
5542 {
5543 case r_up:
5544 case l_up:
5545 case up:
5546 y-=thismove;
5547 break;
5548
5549 case r_down:
5550 case l_down:
5551 case down:
5552 y+=thismove;
5553 break;
5554 }
5555 switch(kb_dir)
5556 {
5557 case l_up:
5558 case l_down:
5559 case left:
5560 x-=thismove;
5561 break;
5562
5563 case r_up:
5564 case r_down:
5565 case right:
5566 x+=thismove;
5567 break;
5568 }
5569 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5570 {
5571 if(!canmove(kb_dir,(zfix)0,0,true))
5572 {
5573 script_knockback_clk=0;
5574 clk3=0;
5575 //Fix to grid
5576 switch(kb_dir)
5577 {
5578 case up:
5579 case down:
5580 break;
5581 default:
5582 if(x < 0)
5583 x = 0;
5584 else if((int32_t(x)&15) > 7)
5585 x=(int32_t(x)&0xF0)+16;
5586 else
5587 x=(int32_t(x)&0xF0);
5588 break;
5589 }
5590 switch(kb_dir)
5591 {
5592 case left:
5593 case right:
5594 break;
5595 default:
5596 if(y < 0)
5597 y = 0;
5598 else if((int32_t(y)&15) > 7)
5599 y=(int32_t(y)&0xF0)+16;
5600 else
5601 y=(int32_t(y)&0xF0);
5602 break;
5603 }
5604 break;
5605 }
5606 }
5607 else
5608 {
5609 if(!scr_canplace(x,y,0,true))
5610 {
5611 script_knockback_clk=0;
5612 clk3=0;
5613 //Fix to grid
5614 if (OFFGRID_ENEMY)
5615 {
5616 switch(kb_dir)
5617 {
5618 case up:
5619 case down:
5620 break;
5621 default:
5622 if(x < 0)
5623 x = 0;
5624 else if((int32_t(x)&7) > 3)
5625 x=(int32_t(x)&0xF8)+8;
5626 else
5627 x=(int32_t(x)&0xF8);
5628 break;
5629 }
5630 switch(kb_dir)
5631 {
5632 case left:
5633 case right:
5634 break;
5635 default:
5636 if(y < 0)
5637 y = 0;
5638 else if((int32_t(y)&7) > 3)
5639 y=(int32_t(y)&0xF8)+8;
5640 else
5641 y=(int32_t(y)&0xF8);
5642 break;
5643 }
5644 }
5645 else
5646 {
5647 switch(kb_dir)
5648 {
5649 case up:
5650 case down:
5651 break;
5652 default:
5653 if(x < 0)
5654 x = 0;
5655 else if((int32_t(x)&15) > 7)
5656 x=(int32_t(x)&0xF0)+16;
5657 else
5658 x=(int32_t(x)&0xF0);
5659 break;
5660 }
5661 switch(kb_dir)
5662 {
5663 case left:
5664 case right:
5665 break;
5666 default:
5667 if(y < 0)
5668 y = 0;
5669 else if((int32_t(y)&15) > 7)
5670 y=(int32_t(y)&0xF0)+16;
5671 else
5672 y=(int32_t(y)&0xF0);
5673 break;
5674 }
5675 }
5676 break;
5677 }
5678
5679 }
5680 }
5681 return true;
5682 37824259 }
5683 // changes enemy's direction, checking restrictions
5684 // rate: 0 = no random changes, 16 = always random change
5685 // homing: 0 = none, 256 = always
5686 // grumble 0 = none, 4 = strongest appetite
5687 520367 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5688 {
5689 520367 int32_t ndir=-1;
5690
5691
4/4
✓ Branch 0 taken 109954 times.
✓ Branch 1 taken 410413 times.
✓ Branch 2 taken 37802 times.
✓ Branch 3 taken 72152 times.
520367 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5692 {
5693 72152 int32_t i = Lwpns.idFirst(wBait);
5694
1/2
✓ Branch 0 taken 72152 times.
✗ Branch 1 not taken.
72152 if(i >= 0) //idfirst returns -1 if it can't find any
5695 {
5696 weapon *w = (weapon*)Lwpns.spr(i);
5697 if (get_qr(qr_FIND_CLOSEST_BAIT))
5698 {
5699 int32_t currentrange;
5700 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5701 else currentrange = -1;
5702 int curid = i;
5703 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5704 for(; i<Lwpns.Count(); ++i)
5705 {
5706 weapon *lw = (weapon*)Lwpns.spr(i);
5707 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5708 {
5709 currentrange = distance(x, y, lw->x, lw->y);
5710 curid = i;
5711 }
5712 }
5713 i = curid;
5714 if (currentrange == -1) i = -1;
5715 }
5716 else
5717 {
5718 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5719 }
5720 if (i >= 0)
5721 {
5722 int32_t bx = Lwpns.spr(i)->x;
5723 int32_t by = Lwpns.spr(i)->y;
5724
5725 if(abs(int32_t(y)-by)>14)
5726 {
5727 ndir = (by<y) ? up : down;
5728 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5729 if(canmove(ndir,special,false))
5730 {
5731 dir=ndir;
5732 return;
5733 }
5734 }
5735
5736 ndir = (bx<x) ? left : right;
5737 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5738 if(canmove(ndir,special,false))
5739 {
5740 dir=ndir;
5741 return;
5742 }
5743 }
5744 }
5745 72152 }
5746
5747
2/2
✓ Branch 0 taken 352478 times.
✓ Branch 1 taken 167889 times.
520367 if((zc_oldrand()&255)<abs(newhoming))
5748 {
5749 167889 ndir = lined_up(8,false);
5750
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167889 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167889 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5751
4/4
✓ Branch 0 taken 45334 times.
✓ Branch 1 taken 122555 times.
✓ Branch 2 taken 5715 times.
✓ Branch 3 taken 39619 times.
167889 if(ndir>=0 && canmove(ndir,special,false))
5752 {
5753 39619 dir=ndir;
5754 39619 return;
5755 }
5756 128270 }
5757
5758 480748 int32_t i=0;
5759
5760
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 1179509 times.
1182844 for(; i<32; i++)
5761 {
5762 1179509 int32_t r=zc_oldrand();
5763
5764
2/2
✓ Branch 0 taken 344692 times.
✓ Branch 1 taken 834817 times.
1179509 if((r&15)<newrate)
5765 344692 ndir=(r>>4)&3;
5766 else
5767 834817 ndir=dir;
5768
5769
2/2
✓ Branch 0 taken 702096 times.
✓ Branch 1 taken 477413 times.
1179509 if(canmove(ndir,special,false))
5770 477413 break;
5771 702096 }
5772
5773
2/2
✓ Branch 0 taken 477413 times.
✓ Branch 1 taken 3335 times.
481501 if(i==32)
5774 {
5775
2/2
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 753 times.
9672 for(ndir=0; ndir<4; ndir++)
5776 {
5777
2/2
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 2582 times.
8919 if(canmove(ndir,special,false))
5778 2582 goto ok;
5779 6337 }
5780
5781
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 693 times.
753 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5782 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5783 753 }
5784
5785 ok:
5786 480748 dir = ndir;
5787 520367 }
5788
5789 2633 void enemy::newdir()
5790 {
5791 2633 newdir(4,0,spw_none);
5792 2633 }
5793
5794 zfix enemy::distance_left()
5795 {
5796 int32_t a2=x.getInt();
5797 int32_t b2=y.getInt();
5798
5799 switch(dir)
5800 {
5801 case up:
5802 return (zfix)(b2&0xF);
5803
5804 case down:
5805 return (zfix)(16-(b2&0xF));
5806
5807 case left:
5808 return (zfix)(a2&0xF);
5809
5810 case right:
5811 return (zfix)(16-(a2&0xF));
5812 }
5813
5814 return (zfix)0;
5815 }
5816
5817 // keeps walking around
5818 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5819 {
5820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5821 return;
5822
5823
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5824 8261 return;
5825
5826
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5827 {
5828 26115 fix_coords(true);
5829 26115 newdir(newrate,newhoming,special);
5830
5831
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5832 clk3=0;
5833 else
5834 26115 clk3=int32_t(16.0/step);
5835 26115 }
5836
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5837 {
5838 45 dir^=1;
5839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5840 else clk3=32767;
5841 45 }
5842
5843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5844 383173 move(step);
5845 391434 }
5846
5847 void enemy::constant_walk()
5848 {
5849 constant_walk(4,0,spw_none);
5850 }
5851
5852 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5853 {
5854 35220 return (newy<<8)+newx;
5855 }
5856
5857 // for variable step rates
5858 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5859 {
5860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5861 return;
5862
5863
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5864 55444 return;
5865
5866 418370 zfix dx = (zfix)0;
5867 418370 zfix dy = (zfix)0;
5868
5869
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5870 {
5871 case 8:
5872 case up:
5873 93441 dy-=step;
5874 93441 break;
5875
5876 case 12:
5877 case down:
5878 97752 dy+=step;
5879 97752 break;
5880
5881 case 14:
5882 case left:
5883 111603 dx-=step;
5884 111603 break;
5885
5886 case 10:
5887 case right:
5888 113743 dx+=step;
5889 113743 break;
5890
5891 case 15:
5892 case l_up:
5893 dx-=step;
5894 dy-=step;
5895 break;
5896
5897 case 9:
5898 case r_up:
5899 dx+=step;
5900 dy-=step;
5901 break;
5902
5903 case 13:
5904 case l_down:
5905 dx-=step;
5906 dy+=step;
5907 break;
5908
5909 case 11:
5910 case r_down:
5911 dx+=step;
5912 dy+=step;
5913 break;
5914 }
5915
5916
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5917 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5918 {
5919 12443 fix_coords();
5920 12443 newdir(newrate,newhoming,special);
5921 12443 clk3=pos(x,y);
5922 12443 }
5923
5924 418370 move(step);
5925 473814 }
5926
5927 // pauses for a while after it makes a complete move (to a new square)
5928 12316472 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5929 {
5930
4/4
✓ Branch 0 taken 79889 times.
✓ Branch 1 taken 12236583 times.
✓ Branch 2 taken 67057 times.
✓ Branch 3 taken 12832 times.
12316472 if(sclk && clk2)
5931 {
5932 12832 clk3=0;
5933 12832 }
5934
5935
11/14
✓ Branch 0 taken 12243450 times.
✓ Branch 1 taken 73022 times.
✓ Branch 2 taken 12243450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12243450 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11776236 times.
✓ Branch 7 taken 467214 times.
✓ Branch 8 taken 11638487 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11635279 times.
✓ Branch 11 taken 3208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11635279 times.
12316472 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5936 {
5937 681193 return;
5938 }
5939
5940
2/2
✓ Branch 0 taken 2132459 times.
✓ Branch 1 taken 9502820 times.
11635279 if(clk2>0)
5941 {
5942 2132459 --clk2;
5943 2132459 return;
5944 }
5945
5946
2/2
✓ Branch 0 taken 410660 times.
✓ Branch 1 taken 9092160 times.
9502820 if(clk3<=0)
5947 {
5948 410660 fix_coords(true);
5949 410660 newdir(newrate,newhoming,special);
5950 410660 clk3=int32_t(16.0/step);
5951
2/2
✓ Branch 0 taken 410465 times.
✓ Branch 1 taken 195 times.
410660 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410660 times.
410660 if(clk2<0)
5953 {
5954 clk2=0;
5955 }
5956
2/2
✓ Branch 0 taken 54758 times.
✓ Branch 1 taken 355902 times.
410660 else if((zc_oldrand()&15)<newhrate)
5957 {
5958 54758 clk2=haltcnt;
5959 54758 return;
5960 }
5961 355902 }
5962
2/2
✓ Branch 0 taken 9089001 times.
✓ Branch 1 taken 3159 times.
9092160 else if(scored)
5963 {
5964 3159 dir^=1;
5965
5966
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5967 5 else clk3=32767;
5968 3159 }
5969
5970
2/2
✓ Branch 0 taken 74649 times.
✓ Branch 1 taken 9373413 times.
9448062 if (step != 0) --clk3;
5971 9448062 move(step);
5972 12316472 }
5973
5974 // 8-directional movement, aligns to 8 pixels
5975 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5976 {
5977 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5978 return;
5979
5980 if(clk3<=0)
5981 {
5982 newdir_8(newrate,newhoming,special);
5983 clk3=int32_t(8.0/step);
5984 if (step == 0) clk3 = 32767;
5985 }
5986
5987 if (step != 0) --clk3;
5988 move(step);
5989 }
5990 // 8-directional movement, aligns to 8 pixels
5991 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5992 {
5993
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5994 return;
5995
5996
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
5997 {
5998 16235 newdir_8(newrate,newhoming,special);
5999 16235 clk3=int32_t(8.0/step);
6000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6001 16235 }
6002
6003
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6004 242393 move(step);
6005 242393 }
6006
6007 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6008 {
6009 if(clk<0 || dying || stunclk || watch || frozenclock)
6010 return;
6011
6012 if(!canmove(dir,step,special,false))
6013 clk3=0;
6014
6015 if(clk2>0)
6016 {
6017 --clk2;
6018 return;
6019 }
6020
6021 if(clk3<=0)
6022 {
6023 newdir_8(newrate,newhoming,special);
6024 clk3=newclk;
6025
6026 if(clk2<0)
6027 {
6028 clk2=0;
6029 }
6030 else if((zc_oldrand()&15)<newhrate)
6031 {
6032 newdir_8(newrate,newhoming,special);
6033 clk2=haltcnt;
6034 return;
6035 }
6036 }
6037
6038 --clk3;
6039 move(step);
6040 }
6041
6042 // 8-directional movement, no alignment
6043 4691075 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6044 {
6045
9/12
✓ Branch 0 taken 4483752 times.
✓ Branch 1 taken 207323 times.
✓ Branch 2 taken 4483752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4457131 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4446084 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4446084 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4446084 times.
4691075 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6046 244991 return;
6047
6048
2/2
✓ Branch 0 taken 4415704 times.
✓ Branch 1 taken 30380 times.
4446084 if(!canmove(dir,step,special,false))
6049 30380 clk3=0;
6050
6051
2/2
✓ Branch 0 taken 3891681 times.
✓ Branch 1 taken 554403 times.
4446084 if(clk3<=0)
6052 {
6053 554403 newdir_8(newrate,newhoming,special);
6054 554403 clk3=newclk;
6055 554403 }
6056
6057 4446084 --clk3;
6058 4446084 move(step);
6059 4691075 }
6060
6061 // same as above but with variable enemy size
6062 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6063 {
6064
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6065 1247 return;
6066
6067
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6068 1334 clk3=0;
6069
6070
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6071 {
6072 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6073 6475 clk3=newclk;
6074 6475 }
6075
6076 93316 --clk3;
6077 93316 move(step);
6078 94563 }
6079
6080 // the variable speed floater movement
6081 // ms is max speed
6082 // ss is step speed
6083 // s is step count
6084 // p is pause count
6085 // g is graduality :)
6086 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6087 3989892 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6088 {
6089 3989892 ++clk2;
6090 3989892 byte over_pit = overpit(this);
6091
6092
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2875098 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
3989892 if(dmisc1 && over_pit) p = 0;
6093
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56213 times.
✓ Branch 2 taken 1570783 times.
✓ Branch 3 taken 2230728 times.
✓ Branch 4 taken 132168 times.
3989892 switch(movestatus)
6094 {
6095 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6096 //! if the conditions prevent it, we jump back to case 2.
6097 case 0: // paused
6098
2/2
✓ Branch 0 taken 54765 times.
✓ Branch 1 taken 1448 times.
56213 if(clk2>=p)
6099 {
6100 1448 movestatus=1;
6101 1448 clk2=0;
6102 1448 }
6103
6104 56213 break;
6105
6106 case 1: // speeding up
6107
1/2
✓ Branch 0 taken 1570783 times.
✗ Branch 1 not taken.
1570783 if (s >= 0)
6108 {
6109
2/2
✓ Branch 0 taken 1559550 times.
✓ Branch 1 taken 11233 times.
1570783 if(clk2<g*s)
6110 {
6111
2/2
✓ Branch 0 taken 1458948 times.
✓ Branch 1 taken 100602 times.
1559550 if(!((clk2-1)%g))
6112 100602 step+=ss;
6113 1559550 }
6114 else
6115 {
6116 11233 movestatus=2;
6117 11233 clk2=0;
6118 }
6119 1570783 }
6120 else
6121 {
6122 if(step < ms)
6123 {
6124 if(!((clk2-1)%g))
6125 {
6126 step+=ss;
6127 if (step >= ms) step = ms;
6128 }
6129 }
6130 else
6131 {
6132 step = ms;
6133 movestatus=2;
6134 clk2=0;
6135 }
6136 }
6137
6138 1570783 break;
6139
6140 case 2: // normal
6141 2230728 step=ms;
6142
6143
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2230728 times.
✓ Branch 2 taken 477682 times.
✓ Branch 3 taken 1753046 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1753046 times.
✓ Branch 6 taken 1750807 times.
✓ Branch 7 taken 2239 times.
2230728 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6144 {
6145
1/2
✓ Branch 0 taken 2239 times.
✗ Branch 1 not taken.
2239 if (s >= 0) step=ss*s;
6146 else step=ms;
6147 2239 movestatus=3;
6148 2239 clk2=0;
6149 2239 }
6150
6151 2230728 break;
6152
6153 case 3: // slowing down
6154
1/2
✓ Branch 0 taken 132168 times.
✗ Branch 1 not taken.
132168 if (s >= 0)
6155 {
6156
2/2
✓ Branch 0 taken 130491 times.
✓ Branch 1 taken 1677 times.
132168 if(clk2<=g*s)
6157 {
6158 { //don't slow down over pits
6159
6160
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 130224 times.
130491 if(over_pit)
6161 {
6162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6163 {
6164 step=ms;
6165 }
6166 267 }
6167 else //can slow down
6168 {
6169
4/4
✓ Branch 0 taken 8036 times.
✓ Branch 1 taken 122188 times.
✓ Branch 2 taken 7668 times.
✓ Branch 3 taken 368 times.
130224 if(!(clk2%g) && !dmisc1)
6170 7668 step-=ss;
6171 }
6172 }
6173
6174
6175 130491 }
6176 else
6177 {
6178 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6179 //this doesn't help keese, as they have a z of 0.
6180 //they always nee to run this check.
6181 {
6182
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1677 if(over_pit &&!dmisc1)
6183 {
6184 --clk2; //if over a pit, don't land, and revert clock change
6185 }
6186 else //can land safely
6187 {
6188 1677 movestatus=0;
6189
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1677 if(dmisc1&&!over_pit)
6190 1115 step=0;
6191 1677 clk2=0;
6192 }
6193 }
6194
6195 }
6196 132168 }
6197 else
6198 {
6199 if(step > 0)
6200 {
6201 if(over_pit)
6202 {
6203 if(dmisc1)
6204 {
6205 step=ms;
6206 }
6207 }
6208 else //can slow down
6209 {
6210 if(!(clk2%g))
6211 step-=ss;
6212 }
6213 }
6214 else
6215 {
6216 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6217 //this doesn't help keese, as they have a z of 0.
6218 //they always nee to run this check.
6219 if(over_pit)
6220 {
6221 step+=ss; //if over a pit, don't land, and revert clock change
6222 }
6223 else //can land safely
6224 {
6225 movestatus=0;
6226 step=0;
6227 clk2=0;
6228 }
6229 }
6230 }
6231
6232 132168 break;
6233 }
6234
6235
2/2
✓ Branch 0 taken 2239722 times.
✓ Branch 1 taken 1750170 times.
3989892 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6236 3989892 }
6237
6238 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6239 {
6240 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6241 }
6242
6243 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6244 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6245 923665 int32_t enemy::lined_up(int32_t range, bool dir8)
6246 {
6247 923665 int32_t lx = Hero.getX();
6248 923665 int32_t ly = Hero.getY();
6249
6250
2/2
✓ Branch 0 taken 38487 times.
✓ Branch 1 taken 885178 times.
923665 if(abs(lx-int32_t(x))<=range)
6251 {
6252
2/2
✓ Branch 0 taken 16116 times.
✓ Branch 1 taken 22371 times.
38487 if(ly<y)
6253 {
6254 16116 return up;
6255 }
6256
6257 22371 return down;
6258 }
6259
6260
2/2
✓ Branch 0 taken 56294 times.
✓ Branch 1 taken 828884 times.
885178 if(abs(ly-int32_t(y))<=range)
6261 {
6262
2/2
✓ Branch 0 taken 30277 times.
✓ Branch 1 taken 26017 times.
56294 if(lx<x)
6263 {
6264 30277 return left;
6265 }
6266
6267 26017 return right;
6268 }
6269
6270
2/2
✓ Branch 0 taken 159834 times.
✓ Branch 1 taken 669050 times.
828884 if(dir8)
6271 {
6272
2/2
✓ Branch 0 taken 252160 times.
✓ Branch 1 taken 416890 times.
669050 if(abs(lx-x)-abs(ly-y)<=range)
6273 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6274 {
6275
2/2
✓ Branch 0 taken 105160 times.
✓ Branch 1 taken 147000 times.
252160 if(ly<y)
6276 {
6277
2/2
✓ Branch 0 taken 56622 times.
✓ Branch 1 taken 48538 times.
105160 if(lx<x)
6278 {
6279 56622 return l_up;
6280 }
6281 else
6282 {
6283 48538 return r_up;
6284 }
6285 }
6286 else
6287 {
6288
2/2
✓ Branch 0 taken 76220 times.
✓ Branch 1 taken 70780 times.
147000 if(lx<x)
6289 {
6290 70780 return l_down;
6291 }
6292 else
6293 {
6294 76220 return r_down;
6295 }
6296 }
6297 }
6298 416890 }
6299
6300 576724 return -1;
6301 923665 }
6302
6303 // returns true if Hero is within 'range' pixels of the enemy
6304 27884 bool enemy::HeroInRange(int32_t range)
6305 {
6306 27884 int32_t lx = Hero.getX();
6307 27884 int32_t ly = Hero.getY();
6308
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6309 }
6310
6311 // place the enemy in line with Hero (red wizzrobes)
6312 4858 void enemy::place_on_axis(bool floater, bool solid_ok)
6313 {
6314
6/6
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 4285 times.
✓ Branch 2 taken 4316 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 573 times.
✓ Branch 5 taken 3743 times.
4858 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6315
6/6
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 4421 times.
✓ Branch 2 taken 4082 times.
✓ Branch 3 taken 776 times.
✓ Branch 4 taken 437 times.
✓ Branch 5 taken 3645 times.
4858 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6316 4858 int32_t pos2=zc_oldrand()%23;
6317 4858 int32_t tried=0;
6318 4858 bool last_resort,placed=false;
6319
6320
6321 4858 do
6322 {
6323
2/2
✓ Branch 0 taken 4432 times.
✓ Branch 1 taken 3104 times.
7536 if(pos2<14)
6324 {
6325 4432 x=(pos2<<4)+16;
6326 4432 y=ly;
6327 4432 }
6328 else
6329 {
6330 3104 x=lx;
6331 3104 y=((pos2-14)<<4)+16;
6332 }
6333
6334 // Don't commit to a last resort if position is out of bounds.
6335
6/6
✓ Branch 0 taken 7199 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6889 times.
✓ Branch 3 taken 310 times.
✓ Branch 4 taken 255 times.
✓ Branch 5 taken 6634 times.
7536 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6336
6337
4/4
✓ Branch 0 taken 3879 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 4912 times.
✓ Branch 3 taken 1443 times.
7536 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6338 {
6339 // Red Wizzrobes should be able to appear on water, but not other
6340 // solid combos; however, they could appear on solid combos in 2.10,
6341 // and some quests depend on that.
6342
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6228 times.
✓ Branch 2 taken 1370 times.
✓ Branch 3 taken 4858 times.
8569 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6343 8569 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6344 4858 placed=true;
6345 8569 }
6346
6347
3/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7340 if(!placed && tried>=22 && last_resort)
6348 {
6349 placed=true;
6350 }
6351
6352 7340 ++tried;
6353 7340 pos2=(pos2+3)%23;
6354
2/2
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
7340 }
6355 7340 while(!placed);
6356
6357
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 1790 times.
4662 if(y==ly)
6358 2872 dir=(x<lx)?right:left;
6359 else
6360 1790 dir=(y<ly)?down:up;
6361
6362 4662 clk2=tried;
6363 4662 }
6364
6365 20213685 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6366 {
6367 20213685 int32_t t = o_tile;
6368 20213685 int32_t b = o_tile;
6369
6370 // Darknuts, but also Wizzrobes and Wallmasters
6371
3/4
✓ Branch 0 taken 8353120 times.
✓ Branch 1 taken 10837883 times.
✓ Branch 2 taken 1022682 times.
✗ Branch 3 not taken.
20213685 switch(family)
6372 {
6373 case eeWALK:
6374
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10332476 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10837883 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6375 {
6376 367468 tile=s_tile;
6377 367468 t=s_tile;
6378 367468 b=s_tile;
6379 367468 }
6380
6381 10837883 break;
6382
6383 case eeTRAP:
6384
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 829116 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1022682 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6385 {
6386 193566 tile=s_tile;
6387 193566 t=s_tile;
6388 193566 b=s_tile;
6389 193566 }
6390
6391 1022682 break;
6392
6393 case eeSPINTILE:
6394 if(misc>=96 && do_animation)
6395 {
6396 tile=o_tile+frames*ndir;
6397 t=tile;
6398 }
6399
6400 break;
6401 }
6402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20213685 times.
20213685 if ( do_animation )
6403 {
6404
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20016643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19749512 times.
20213685 if(ndir!=0) switch(frames)
6405 {
6406 case 2:
6407 267131 tiledir_small(dir,ndir==4);
6408 267131 break;
6409
6410 case 3:
6411 tiledir_three(dir);
6412 break;
6413
6414 case 4:
6415 19749512 tiledir(dir,ndir==4);
6416 19749512 break;
6417 20016643 }
6418
6419
2/2
✓ Branch 0 taken 10837883 times.
✓ Branch 1 taken 9375802 times.
20213685 if(family==eeWALK)
6420
6/6
✓ Branch 0 taken 10776874 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8177902 times.
✓ Branch 3 taken 2659981 times.
✓ Branch 4 taken 2644258 times.
✓ Branch 5 taken 15723 times.
10837883 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6421 else
6422 9375802 tile+=f4;
6423 20213685 }
6424 20213685 return b;
6425 }
6426
6427 void enemy::tiledir_three(int32_t ndir)
6428 {
6429 if ( !do_animation ) return;
6430 flip=0;
6431
6432 switch(ndir)
6433 {
6434 case right:
6435 tile+=3;
6436 [[fallthrough]];
6437
6438 case left:
6439 tile+=3;
6440 [[fallthrough]];
6441
6442 case down:
6443 tile+=3;
6444 [[fallthrough]];
6445
6446 case up:
6447 break;
6448 }
6449 }
6450
6451 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6452 {
6453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6454 267131 flip=0;
6455
6456
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6457 {
6458 case 8:
6459 case up:
6460 53829 break;
6461
6462 case 12:
6463 case down:
6464 54679 tile+=2;
6465 54679 break;
6466
6467 case 14:
6468 case left:
6469 67727 tile+=4;
6470 67727 break;
6471
6472 case 10:
6473 case right:
6474 71182 tile+=6;
6475 71182 break;
6476
6477 case 9:
6478 case r_up:
6479
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6480 5706 break;
6481
6482 tile+=10;
6483 break;
6484
6485 case 11:
6486 case r_down:
6487
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6488 5154 tile+=2;
6489 else
6490 tile+=14;
6491
6492 5154 break;
6493
6494 case 13:
6495 case l_down:
6496
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6497 4872 tile+=2;
6498 else
6499 tile+=12;
6500
6501 4872 break;
6502
6503 case 15:
6504 case l_up:
6505
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6506 3982 break;
6507
6508 tile+=8;
6509 break;
6510
6511 default:
6512 //dir=(zc_oldrand()*100)%8;
6513 //tiledir_small(dir);
6514 // flip=zc_oldrand()&3;
6515 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6516 break;
6517 }
6518 267131 }
6519
6520 23069632 void enemy::tiledir(int32_t ndir, bool fourdir)
6521 {
6522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23069632 times.
23069632 if ( !do_animation ) return;
6523 23069632 flip=0;
6524
6525
9/9
✓ Branch 0 taken 4483892 times.
✓ Branch 1 taken 4141765 times.
✓ Branch 2 taken 5412757 times.
✓ Branch 3 taken 5175571 times.
✓ Branch 4 taken 825768 times.
✓ Branch 5 taken 1018734 times.
✓ Branch 6 taken 1099241 times.
✓ Branch 7 taken 845055 times.
✓ Branch 8 taken 66849 times.
23069632 switch(ndir)
6526 {
6527 case 8:
6528 case up:
6529 4483892 break;
6530
6531 case 12:
6532 case down:
6533 4141765 tile+=4;
6534 4141765 break;
6535
6536 case 14:
6537 case left:
6538 5412757 tile+=8;
6539 5412757 break;
6540
6541 case 10:
6542 case right:
6543 5175571 tile+=12;
6544 5175571 break;
6545
6546 case 9:
6547 case r_up:
6548
2/2
✓ Branch 0 taken 88653 times.
✓ Branch 1 taken 737115 times.
825768 if(fourdir)
6549 88653 break;
6550 else
6551 737115 tile+=24;
6552
6553 737115 break;
6554
6555 case 11:
6556 case r_down:
6557
2/2
✓ Branch 0 taken 101949 times.
✓ Branch 1 taken 916785 times.
1018734 if(fourdir)
6558 101949 tile+=4;
6559 else
6560 916785 tile+=32;
6561
6562 1018734 break;
6563
6564 case 13:
6565 case l_down:
6566
2/2
✓ Branch 0 taken 105945 times.
✓ Branch 1 taken 993296 times.
1099241 if(fourdir)
6567 105945 tile+=4;
6568 else
6569 993296 tile+=28;
6570
6571 1099241 break;
6572
6573 case 15:
6574 case l_up:
6575
2/2
✓ Branch 0 taken 82760 times.
✓ Branch 1 taken 762295 times.
845055 if(fourdir)
6576 82760 break;
6577 else
6578 762295 tile+=20;
6579
6580 762295 break;
6581
6582 default:
6583 //dir=(zc_oldrand()*100)%8;
6584 //tiledir(dir);
6585 // flip=zc_oldrand()&3;
6586 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6587 66849 break;
6588 }
6589 23069632 }
6590
6591 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6592 {
6593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6594 3868 flip=0;
6595
6596
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6597 {
6598 case 8:
6599 case up:
6600 297 break;
6601
6602 case 12:
6603 case down:
6604 tile+=8;
6605 break;
6606
6607 case 14:
6608 case left:
6609 195 tile+=40;
6610 195 break;
6611
6612 case 10:
6613 case right:
6614 179 tile+=48;
6615 179 break;
6616
6617 case 9:
6618 case r_up:
6619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6620 break;
6621
6622 306 tile+=88;
6623 306 break;
6624
6625 case 11:
6626 case r_down:
6627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6628 tile+=8;
6629 else
6630 1235 tile+=128;
6631
6632 1235 break;
6633
6634 case 13:
6635 case l_down:
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6637 tile+=8;
6638 else
6639 1324 tile+=120;
6640
6641 1324 break;
6642
6643 case 15:
6644 case l_up:
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6646 break;
6647
6648 332 tile+=80;
6649 332 break;
6650
6651 default:
6652 //dir=(zc_oldrand()*100)%8;
6653 //tiledir_big(dir);
6654 // flip=zc_oldrand()&3;
6655 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6656 break;
6657 }
6658 3868 }
6659
6660 39895319 void enemy::update_enemy_frame()
6661 {
6662
4/4
✓ Branch 0 taken 39893013 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 39893006 times.
39895319 if(fallclk||drownclk) return;
6663
1/2
✓ Branch 0 taken 39893006 times.
✗ Branch 1 not taken.
39893006 if (!do_animation)
6664 return;
6665
6666
4/4
✓ Branch 0 taken 1475933 times.
✓ Branch 1 taken 38417073 times.
✓ Branch 2 taken 1473926 times.
✓ Branch 3 taken 2007 times.
39893006 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6667
6668
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39893006 if(get_qr(qr_ANONE_NOANIM)
6669
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39893006 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39893006 && anim == aNONE && family != eeGUY)
6670 return;
6671
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39521630 times.
39893006 int32_t newfrate = zc_max(frate,4);
6672 39893006 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6673 39893006 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6674
2/2
✓ Branch 0 taken 29900304 times.
✓ Branch 1 taken 9992702 times.
39893006 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6675 39893006 tile = o_tile;
6676 39893006 int32_t basetile = o_tile;
6677 39893006 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6678 39893006 bool ignore_extend = false;
6679
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 201224 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4982387 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1519575 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 686882 times.
✓ Branch 22 taken 1691672 times.
✓ Branch 23 taken 1133827 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4117708 times.
✓ Branch 27 taken 7475916 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582791 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880199 times.
✓ Branch 32 taken 218668 times.
✓ Branch 33 taken 1812060 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 6953976 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
39893006 switch(anim)
6680 {
6681
6682 case aDONGO:
6683 {
6684 69324 int32_t fr = stunclk>0 ? 16 : 8;
6685
6686
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6687 {
6688 // bloated
6689
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6690 {
6691 case up:
6692 960 tile+=9;
6693 960 flip=0;
6694 960 xofs=0;
6695 960 dummy_int[1]=0; //no additional tiles
6696 960 break;
6697
6698 case down:
6699 960 tile+=7;
6700 960 flip=0;
6701 960 xofs=0;
6702 960 dummy_int[1]=0; //no additional tiles
6703 960 break;
6704
6705 case left:
6706 1664 flip=1;
6707 1664 tile+=4;
6708 1664 xofs=16;
6709 1664 dummy_int[1]=1; //second tile is next tile
6710 1664 break;
6711
6712 case right:
6713 896 flip=0;
6714 896 tile+=5;
6715 896 xofs=16;
6716 896 dummy_int[1]=-1; //second tile is previous tile
6717 896 break;
6718 }
6719 4480 }
6720
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6721 {
6722 // normal
6723
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6724 {
6725 case up:
6726 13652 tile+=8;
6727 13652 flip=(clk&fr)?1:0;
6728 13652 xofs=0;
6729 13652 dummy_int[1]=0; //no additional tiles
6730 13652 break;
6731
6732 case down:
6733 15374 tile+=6;
6734 15374 flip=(clk&fr)?1:0;
6735 15374 xofs=0;
6736 15374 dummy_int[1]=0; //no additional tiles
6737 15374 break;
6738
6739 case left:
6740 19615 flip=1;
6741 19615 tile+=(clk&fr)?2:0;
6742 19615 xofs=16;
6743 19615 dummy_int[1]=1; //second tile is next tile
6744 19615 break;
6745
6746 case right:
6747 15086 flip=0;
6748 15086 tile+=(clk&fr)?3:1;
6749 15086 xofs=16;
6750 15086 dummy_int[1]=-1; //second tile is next tile
6751 15086 break;
6752 }
6753 63727 }
6754 }
6755 69324 break;
6756
6757 case aNEWDONGO:
6758 {
6759 53456 int32_t fr4=0;
6760
6761
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6762 {
6763 // bloated
6764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6765 {
6766 2752 fr4=3;
6767 2752 }
6768
6769
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6770 {
6771 2107 fr4=2;
6772 2107 }
6773
6774
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6775 {
6776 1419 fr4=1;
6777 1419 }
6778
6779
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6780 {
6781 731 fr4=0;
6782 731 }
6783
6784
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6785 {
6786 case up:
6787 256 xofs=0;
6788 256 tile+=8+fr4;
6789 256 dummy_int[1]=0; //no additional tiles
6790 256 break;
6791
6792 case down:
6793 576 xofs=0;
6794 576 tile+=12+fr4;
6795 576 dummy_int[1]=0; //no additional tiles
6796 576 break;
6797
6798 case left:
6799 704 tile+=29+(2*fr4);
6800 704 xofs=16;
6801 704 dummy_int[1]=-1; //second tile is previous tile
6802 704 break;
6803
6804 case right:
6805 1216 tile+=49+(2*fr4);
6806 1216 xofs=16;
6807 1216 dummy_int[1]=-1; //second tile is previous tile
6808 1216 break;
6809 }
6810 2752 }
6811
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6812 {
6813 // normal
6814
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6815 {
6816 case up:
6817 9234 xofs=0;
6818 9234 tile+=((clk&12)>>2);
6819 9234 dummy_int[1]=0; //no additional tiles
6820 9234 break;
6821
6822 case down:
6823 9871 xofs=0;
6824 9871 tile+=4+((clk&12)>>2);
6825 9871 dummy_int[1]=0; //no additional tiles
6826 9871 break;
6827
6828 case left:
6829 15025 tile+=21+((clk&12)>>1);
6830 15025 xofs=16;
6831 15025 dummy_int[1]=-1; //second tile is previous tile
6832 15025 break;
6833
6834 case right:
6835 15676 flip=0;
6836 15676 tile+=41+((clk&12)>>1);
6837 15676 xofs=16;
6838 15676 dummy_int[1]=-1; //second tile is previous tile
6839 15676 break;
6840 }
6841 49806 }
6842 }
6843 53456 break;
6844
6845 case aDONGOBS:
6846 {
6847 38833 int32_t fr4=0;
6848
6849
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6850 {
6851 // bloated
6852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6853 {
6854 2688 fr4=3;
6855 2688 }
6856
6857
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6858 {
6859 2058 fr4=2;
6860 2058 }
6861
6862
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6863 {
6864 1386 fr4=1;
6865 1386 }
6866
6867
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6868 {
6869 714 fr4=0;
6870 714 }
6871
6872
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6873 {
6874 case up:
6875 256 tile+=28+fr4;
6876 256 yofs+=8;
6877 256 dummy_int[1]=-20; //second tile change
6878 256 dummy_int[2]=0; //new xofs change
6879 256 dummy_int[3]=-16; //new xofs change
6880 256 break;
6881
6882 case down:
6883 384 tile+=12+fr4;
6884 384 yofs-=8;
6885 384 dummy_int[1]=20; //second tile change
6886 384 dummy_int[2]=0; //new xofs change
6887 384 dummy_int[3]=16; //new xofs change
6888 384 break;
6889
6890 case left:
6891 1024 tile+=49+(2*fr4);
6892 1024 xofs+=8;
6893 1024 dummy_int[1]=-1; //second tile change
6894 1024 dummy_int[2]=-16; //new xofs change
6895 1024 dummy_int[3]=0; //new xofs change
6896 1024 break;
6897
6898 case right:
6899 1024 tile+=69+(2*fr4);
6900 1024 xofs+=8;
6901 1024 dummy_int[1]=-1; //second tile change
6902 1024 dummy_int[2]=-16; //new xofs change
6903 1024 dummy_int[3]=0; //new xofs change
6904 1024 break;
6905 }
6906 2688 }
6907
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6908 {
6909 // normal
6910
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6911 {
6912 case up:
6913 7136 tile+=20+((clk&24)>>3);
6914 7136 yofs+=8;
6915 7136 dummy_int[1]=-20; //second tile change
6916 7136 dummy_int[2]=0; //new xofs change
6917 7136 dummy_int[3]=-16; //new xofs change
6918 7136 break;
6919
6920 case down:
6921 6672 tile+=4+((clk&24)>>3);
6922 6672 yofs-=8;
6923 6672 dummy_int[1]=20; //second tile change
6924 6672 dummy_int[2]=0; //new xofs change
6925 6672 dummy_int[3]=16; //new xofs change
6926 6672 break;
6927
6928 case left:
6929 11075 xofs=-8;
6930 11075 tile+=40+((clk&24)>>2);
6931 11075 dummy_int[1]=1; //second tile change
6932 11075 dummy_int[2]=16; //new xofs change
6933 11075 dummy_int[3]=0; //new xofs change
6934 11075 break;
6935
6936 case right:
6937 10601 tile+=60+((clk&24)>>2);
6938 10601 xofs=-8;
6939 10601 dummy_int[1]=1; //second tile change
6940 10601 dummy_int[2]=16; //new xofs change
6941 10601 dummy_int[3]=0; //new xofs change
6942 10601 break;
6943 }
6944 35484 }
6945 }
6946 38833 break;
6947
6948 case aWIZZ:
6949 {
6950 // if(d->misc1)
6951
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6952 {
6953
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6954 {
6955 91127 ++tile;
6956 91127 }
6957 182184 }
6958 else
6959 {
6960
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6961 {
6962 136489 ++tile;
6963 136489 }
6964 }
6965
6966
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6967 {
6968 case 9:
6969 case 15:
6970 case up:
6971 76094 tile+=2;
6972 76094 break;
6973
6974 case down:
6975 76591 break;
6976
6977 case 13:
6978 case left:
6979 157108 flip=1;
6980 157108 break;
6981
6982 default:
6983 145581 flip=0;
6984 145581 break;
6985 }
6986 }
6987 455374 break;
6988
6989 case aNEWWIZZ:
6990 {
6991 1519575 tiledir(dir,true);
6992
6993 // if(d->misc1) //walking wizzrobe
6994
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 777151 times.
1519575 if(dmisc1) //walking wizzrobe
6995 {
6996
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
6997 {
6998 369103 tile+=2;
6999 369103 }
7000
7001
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7002 {
7003 370339 tile+=1;
7004 370339 }
7005
7006
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7007 {
7008
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7009 {
7010 79162 tile+=40;
7011 79162 }
7012 742424 }
7013 742424 }
7014 else
7015 {
7016
4/4
✓ Branch 0 taken 710492 times.
✓ Branch 1 taken 66659 times.
✓ Branch 2 taken 167559 times.
✓ Branch 3 taken 542933 times.
777151 if(dummy_bool[1]||dummy_bool[2])
7017 {
7018 234218 tile+=20;
7019
7020
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 167568 times.
234218 if(dummy_bool[2])
7021 {
7022 167568 tile+=20;
7023 167568 }
7024 234218 }
7025
7026 777151 tile+=((frame>>1)&3);
7027 }
7028 }
7029 1519575 break;
7030
7031 case a3FRM:
7032 {
7033
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7034 }
7035 197042 break;
7036
7037 case a3FRM4DIR:
7038 {
7039 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7040 }
7041 break;
7042
7043 case aVIRE:
7044 {
7045
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7046 {
7047 29292 tile+=2;
7048 29292 }
7049
7050 128880 tile+=fx;
7051 }
7052 128880 break;
7053
7054 case aROPE:
7055 {
7056 220021 tile+=(1-fx);
7057 220021 flip = dir==left ? 1:0;
7058 }
7059 220021 break;
7060
7061 case aZORA:
7062 {
7063 int32_t dl;
7064
7065
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7066 {
7067 46739 dl=clk+5;
7068 46739 goto waves2;
7069 }
7070
7071
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7072
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7073 else
7074 {
7075 92458 dl=clk-36-66;
7076 waves2:
7077 139197 tile=((dl/11)&1)+s_tile;
7078 139197 basetile = s_tile;
7079 }
7080 }
7081 221637 break;
7082
7083 case aNEWZORA:
7084 {
7085 686882 f4=(clk/16)%4;
7086
7087 686882 tiledir(dir,true);
7088 int32_t dl;
7089
7090
4/4
✓ Branch 0 taken 485838 times.
✓ Branch 1 taken 201044 times.
✓ Branch 2 taken 249250 times.
✓ Branch 3 taken 236588 times.
686882 if((clk>35)&&(clk<36+67)) //surfaced
7091 {
7092
4/4
✓ Branch 0 taken 202239 times.
✓ Branch 1 taken 34349 times.
✓ Branch 2 taken 29164 times.
✓ Branch 3 taken 173075 times.
236588 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7093 {
7094 173075 tile+=80;
7095 173075 } //mouth closed
7096 else
7097 {
7098 63513 tile+=40;
7099 }
7100
7101 236588 tile+=f4;
7102 236588 }
7103 else
7104 {
7105
2/2
✓ Branch 0 taken 201044 times.
✓ Branch 1 taken 249250 times.
450294 if(clk<36)
7106 {
7107 201044 dl=clk+5;
7108 201044 }
7109 else
7110 {
7111 249250 dl=clk-36-66;
7112 }
7113
7114 450294 tile+=((dl/5)&3);
7115 }
7116 }
7117 686882 break;
7118
7119 case a4FRM4EYE:
7120 case a2FRM4EYE:
7121 case a4FRM8EYE:
7122 case a4FRM8EYEB: //big version
7123 case a4FRM4EYEB:
7124 {
7125 836734 tilerows = 2;
7126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7128 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7129 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7130 836734 int32_t lookat=zc_oldrand()&15;
7131
7132
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7133 {
7134 210774 lookat=l_down;
7135 210774 }
7136
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7137 {
7138 226850 lookat=down;
7139 226850 }
7140
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7141 {
7142 108837 lookat=r_down;
7143 108837 }
7144
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7145 {
7146 70395 lookat=right;
7147 70395 }
7148
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7149 {
7150 35067 lookat=r_up;
7151 35067 }
7152
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7153 {
7154 25436 lookat=up;
7155 25436 }
7156
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7157 {
7158 36803 lookat=l_up;
7159 36803 }
7160 else
7161 {
7162 122572 lookat=left;
7163 }
7164
7165 836734 int32_t dir2 = dir;
7166 836734 dir = lookat;
7167
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7168 else
7169 {
7170 tiledir_big(dir,(anim == a4FRM4EYEB));
7171 tile+=2*f4;
7172 ignore_extend = true;
7173 }
7174 836734 dir = dir2;
7175 }
7176 836734 break;
7177
7178 case aFLIP:
7179 {
7180 1691672 flip = f2&1;
7181 }
7182 1691672 break;
7183
7184 case a2FRM:
7185 {
7186 1133827 tile += (1-f2);
7187 }
7188 1133827 break;
7189
7190 case a2FRMB:
7191 {
7192 tile+= 2*(1-f2);
7193 ignore_extend = true;
7194 }
7195 break;
7196
7197 case a2FRM4DIR:
7198 {
7199 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7200 }
7201 267131 break;
7202
7203 case a4FRM4DIRF:
7204 {
7205 4117708 basetile = n_frame_n_dir(4,4,f4);
7206
7207
2/2
✓ Branch 0 taken 2717716 times.
✓ Branch 1 taken 1399992 times.
4117708 if(clk2>0) //stopped to fire
7208 {
7209 1399992 tile+=20;
7210
7211
2/2
✓ Branch 0 taken 697526 times.
✓ Branch 1 taken 702466 times.
1399992 if(clk2<17) //firing
7212 {
7213 702466 tile+=20;
7214 702466 }
7215 1399992 }
7216 }
7217 4117708 break;
7218
7219 case a4FRM4DIR:
7220 {
7221 7475916 basetile = n_frame_n_dir(4,4,f4);
7222 }
7223 7475916 break;
7224
7225 case a4FRM8DIRF:
7226 {
7227 tilerows = 2;
7228 basetile = n_frame_n_dir(4,8,f4);
7229
7230 if(clk2>0) //stopped to fire
7231 {
7232 tile+=40;
7233
7234 if(clk2<17) //firing
7235 {
7236 tile+=40;
7237 }
7238 }
7239 }
7240 break;
7241
7242 case a4FRM8DIRB:
7243 case a4FRM8DIRFB:
7244 {
7245 3868 tilerows = 2;
7246 3868 tiledir_big(dir,false);
7247 3868 tile+=2*f4;
7248
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7249 {
7250 tile+=80;
7251
7252 if(clk2<17) //firing
7253 {
7254 tile+=80;
7255 }
7256 }
7257 3868 ignore_extend = true;
7258 }
7259 3868 break;
7260
7261 case a4FRM4DIRB:
7262 case a4FRM4DIRFB:
7263 {
7264 tilerows = 2;
7265 tiledir_big(dir,true);
7266 tile+=2*f4;
7267 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7268 {
7269 tile+=40;
7270
7271 if(clk2<17) //firing
7272 {
7273 tile+=40;
7274 }
7275 }
7276 ignore_extend = true;
7277 }
7278 break;
7279
7280 case aOCTO:
7281 {
7282
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165605 times.
✓ Branch 4 taken 157127 times.
582791 switch(dir)
7283 {
7284 case up:
7285 122459 flip = 2;
7286 122459 break;
7287
7288 case down:
7289 133448 flip = 0;
7290 133448 break;
7291
7292 case left:
7293 165605 flip = 0;
7294 165605 tile += 2;
7295 165605 break;
7296
7297 case right:
7298 157127 flip = 1;
7299 157127 tile += 2;
7300 157127 break;
7301 }
7302
7303 582791 tile+=f2;
7304 }
7305 582791 break;
7306
7307 case aWALK:
7308 {
7309
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7310 {
7311 case up:
7312 248704 tile+=3;
7313 248704 flip = f2;
7314 248704 break;
7315
7316 case down:
7317 267165 tile+=2;
7318 267165 flip = f2;
7319 267165 break;
7320
7321 case left:
7322 331694 flip=1;
7323 331694 tile += f2;
7324 331694 break;
7325
7326 case right:
7327 325802 flip=0;
7328 325802 tile += f2;
7329 325802 break;
7330 }
7331 }
7332 1178979 break;
7333
7334 case aDWALK:
7335 {
7336
3/4
✓ Branch 0 taken 92353 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92353 times.
✗ Branch 3 not taken.
880199 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7337 {
7338 tile=s_tile;
7339 basetile = s_tile;
7340 }
7341
7342
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260962 times.
✓ Branch 4 taken 255928 times.
880199 switch(dir)
7343 {
7344 case up:
7345 177728 tile+=2;
7346 177728 flip=f2;
7347 177728 break;
7348
7349 case down:
7350 185581 flip=0;
7351 185581 tile+=(1-f2);
7352 185581 break;
7353
7354 case left:
7355 260962 flip=1;
7356 260962 tile+=(3+f2);
7357 260962 break;
7358
7359 case right:
7360 255928 flip=0;
7361 255928 tile+=(3+f2);
7362 255928 break;
7363 }
7364 }
7365 880199 break;
7366
7367 case aTEK:
7368 {
7369
2/2
✓ Branch 0 taken 139654 times.
✓ Branch 1 taken 79014 times.
218668 if(misc==0)
7370 {
7371 79014 tile += f2;
7372 79014 }
7373
2/2
✓ Branch 0 taken 72936 times.
✓ Branch 1 taken 66718 times.
139654 else if(misc!=1)
7374 {
7375 66718 ++tile;
7376 66718 }
7377 }
7378 218668 break;
7379
7380 case aNEWTEK:
7381 {
7382
2/2
✓ Branch 0 taken 474700 times.
✓ Branch 1 taken 1337360 times.
1812060 if(step<0) //up
7383 {
7384
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235321 times.
✓ Branch 2 taken 239379 times.
474700 switch(clk3)
7385 {
7386 case left:
7387 235321 flip=0;
7388 235321 tile+=20;
7389 235321 break;
7390
7391 case right:
7392 239379 flip=0;
7393 239379 tile+=24;
7394 239379 break;
7395 }
7396 474700 }
7397
2/2
✓ Branch 0 taken 54741 times.
✓ Branch 1 taken 1282619 times.
1337360 else if(step==0)
7398 {
7399
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40562 times.
✓ Branch 2 taken 14179 times.
54741 switch(clk3)
7400 {
7401 case left:
7402 40562 flip=0;
7403 40562 tile+=8;
7404 40562 break;
7405
7406 case right:
7407 14179 flip=0;
7408 14179 tile+=12;
7409 14179 break;
7410 }
7411 54741 } //down
7412 else
7413 {
7414
3/3
✓ Branch 0 taken 104875 times.
✓ Branch 1 taken 592792 times.
✓ Branch 2 taken 584952 times.
1282619 switch(clk3)
7415 {
7416 case left:
7417 592792 flip=0;
7418 592792 tile+=28;
7419 592792 break;
7420
7421 case right:
7422 584952 flip=0;
7423 584952 tile+=32;
7424 584952 break;
7425 }
7426 }
7427
7428
2/2
✓ Branch 0 taken 1232959 times.
✓ Branch 1 taken 579101 times.
1812060 if(misc==0)
7429 {
7430 579101 tile+=f4;
7431 579101 }
7432
2/2
✓ Branch 0 taken 577625 times.
✓ Branch 1 taken 655334 times.
1232959 else if(misc!=1)
7433 {
7434 655334 tile+=2;
7435 655334 }
7436 }
7437 1812060 break;
7438
7439 case aARMOS:
7440 {
7441
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7442 {
7443 5401 tile += fx;
7444
7445
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7446 1197 tile += 2;
7447 5401 }
7448 }
7449 8628 break;
7450
7451 case aARMOS4:
7452 {
7453
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28875 times.
✓ Branch 2 taken 86028 times.
✓ Branch 3 taken 43591 times.
✓ Branch 4 taken 42730 times.
201224 switch(dir)
7454 {
7455 case up:
7456 28875 flip=0;
7457 28875 break;
7458
7459 case down:
7460 86028 flip=0;
7461 86028 tile+=4;
7462 86028 break;
7463
7464 case left:
7465 43591 flip=0;
7466 43591 tile+=8;
7467 43591 break;
7468
7469 case right:
7470 42730 flip=0;
7471 42730 tile+=12;
7472 42730 break;
7473 }
7474
7475
2/2
✓ Branch 0 taken 59706 times.
✓ Branch 1 taken 141518 times.
201224 if(!fading)
7476 {
7477 141518 tile+=f4;
7478 141518 }
7479 }
7480 201224 break;
7481
7482 case aGHINI:
7483 {
7484
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7485 {
7486 case 8:
7487 case 9:
7488 case up:
7489 28037 ++tile;
7490 28037 flip=0;
7491 28037 break;
7492
7493 case 15:
7494 452 ++tile;
7495 452 flip=1;
7496 452 break;
7497
7498 case 10:
7499 case 11:
7500 case right:
7501 32092 flip=1;
7502 32092 break;
7503
7504 default:
7505 72763 flip=0;
7506 72763 break;
7507 }
7508 }
7509 133344 break;
7510
7511 case a2FRMPOS:
7512 {
7513 1755010 tile+=posframe;
7514 }
7515 1755010 break;
7516
7517 case a4FRMPOS4DIR:
7518 {
7519 363745 basetile = n_frame_n_dir(4,4,0);
7520 // tile+=f2;
7521 363745 tile+=posframe;
7522 }
7523 363745 break;
7524
7525 case a4FRMPOS4DIRF:
7526 {
7527 1433 basetile = n_frame_n_dir(4,4,0);
7528
7529
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7530 {
7531 197 tile+=20;
7532
7533
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7534 {
7535 64 tile+=20;
7536 64 }
7537 197 }
7538
7539 // tile+=f2;
7540 1433 tile+=posframe;
7541 }
7542 1433 break;
7543
7544 case a4FRMPOS8DIR:
7545 {
7546 6953976 tilerows = 2;
7547 6953976 int32_t n = tile;
7548 6953976 basetile = n_frame_n_dir(4,8,0);
7549 // tile+=f2;
7550 6953976 tile+=posframe;
7551 }
7552 6953976 break;
7553
7554 case a4FRMPOS8DIRF:
7555 {
7556 tilerows = 2;
7557 basetile = n_frame_n_dir(4,8,0);
7558
7559 if(clk2>0) //stopped to fire
7560 {
7561 tile+=40;
7562
7563 if(clk2<17) //firing
7564 {
7565 tile+=40;
7566 }
7567 }
7568
7569 tile+=posframe;
7570 }
7571 break;
7572
7573 case aNEWLEV:
7574 {
7575 747030 tiledir(dir,true);
7576
7577
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7578 {
7579 case -1:
7580 case 0:
7581 258994 return;
7582
7583 case 1:
7584
7585 // case 5: cs = d->misc2; break;
7586 case 5:
7587 115368 cs = dmisc2;
7588 115368 break;
7589
7590 case 2:
7591 case 4:
7592 48980 tile += 20;
7593 48980 break;
7594
7595 case 3:
7596 323688 tile += 40;
7597 323688 break;
7598 }
7599
7600 488036 tile+=f4;
7601 }
7602 488036 break;
7603
7604 case aLEV:
7605 {
7606 276997 f4 = ((clk/5)&1);
7607
7608
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7609 {
7610 case -1:
7611 case 0:
7612 127945 return;
7613
7614 case 1:
7615
7616 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7617 case 5:
7618 33336 tile += (f2) ? 1 : 0;
7619 33336 cs = dmisc2;
7620 33336 break;
7621
7622 case 2:
7623 case 4:
7624 14658 tile += 2;
7625 14658 break;
7626
7627 case 3:
7628 101058 tile += (f4) ? 4 : 3;
7629 101058 break;
7630 }
7631 }
7632 149052 break;
7633
7634 case aWALLM:
7635 {
7636
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7637 {
7638 139764 tile += f2;
7639 139764 }
7640 }
7641 140514 break;
7642
7643 case aNEWWALLM:
7644 {
7645 366633 int32_t tempdir=0;
7646
7647
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7648 {
7649 case 1:
7650 case 2:
7651 43340 tempdir=clk3;
7652 43340 break;
7653
7654 case 3:
7655 case 4:
7656 case 5:
7657 38855 tempdir=dir;
7658 38855 break;
7659
7660 case 6:
7661 case 7:
7662 8438 tempdir=clk3^1;
7663 8438 break;
7664 }
7665
7666 366633 tiledir(tempdir,true);
7667
7668
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7669 {
7670 364725 tile+=f4;
7671 364725 }
7672 }
7673 366633 break;
7674
7675 case a4FRMNODIR:
7676 {
7677 171508 tile+=f4;
7678 }
7679 171508 break;
7680
7681 } // switch(d->anim)
7682
7683 // flashing
7684 // if(d->flags & guy_flashing)
7685
2/2
✓ Branch 0 taken 38762439 times.
✓ Branch 1 taken 743628 times.
39506067 if(flags & guy_flashing)
7686 {
7687 743628 cs = (frame&3) + 6;
7688 743628 }
7689
7690
2/2
✓ Branch 0 taken 39095119 times.
✓ Branch 1 taken 410948 times.
39506067 if(flags&guy_transparent)
7691 {
7692 410948 drawstyle=1;
7693 410948 }
7694
7695 39506067 int32_t change = tile-basetile;
7696
7697
3/6
✓ Branch 0 taken 1944681 times.
✓ Branch 1 taken 37561386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1944681 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39506067 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7698 {
7699
2/2
✓ Branch 0 taken 1681508 times.
✓ Branch 1 taken 263173 times.
1944681 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7700 {
7701 1681508 tile=basetile+txsz*change;
7702 1681508 }
7703 else
7704 {
7705 263173 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7706 }
7707 1944681 }
7708 else
7709 {
7710 37561386 tile=basetile+change;
7711 }
7712 39895319 }
7713
7714 81077 int32_t wpnsfx(int32_t wpn)
7715 {
7716
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21754 times.
✓ Branch 2 taken 665 times.
✓ Branch 3 taken 29990 times.
✓ Branch 4 taken 17706 times.
✓ Branch 5 taken 10962 times.
81077 switch(wpn)
7717 {
7718 case ewFireTrail:
7719 case ewFlame:
7720 case ewFlame2Trail:
7721 case ewFlame2:
7722 21754 return WAV_FIRE;
7723
7724 case ewWind:
7725 case ewMagic:
7726 665 return WAV_WAND;
7727
7728 case ewIce:
7729 return WAV_ZN1ICE;
7730
7731 case ewRock:
7732
2/2
✓ Branch 0 taken 2848 times.
✓ Branch 1 taken 8114 times.
10962 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7733 8114 break;
7734
7735 case ewFireball2:
7736 case ewFireball:
7737
2/2
✓ Branch 0 taken 2646 times.
✓ Branch 1 taken 27344 times.
29990 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7738 27344 }
7739
7740 53164 return -1;
7741 81077 }
7742
7743 76630804 int32_t enemy::run_script(int32_t mode)
7744 {
7745
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76630548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76630804 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7746
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76630548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76630548 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7747 76630548 return RUNSCRIPT_OK;
7748 auto scrty = *get_scrtype();
7749 auto uid = getUID();
7750 if(!FFCore.doscript(scrty,uid))
7751 return RUNSCRIPT_OK;
7752 int32_t ret = RUNSCRIPT_OK;
7753 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7754 switch(mode)
7755 {
7756 case MODE_NORMAL:
7757 return ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7758 case MODE_WAITDRAW:
7759 if(waitdraw)
7760 {
7761 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7762 waitdraw = false;
7763 }
7764 break;
7765 }
7766 return ret;
7767 76630804 }
7768 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7769 {
7770 return al_map_rgba(255,0,0,opacity);
7771 }
7772
7773 // good guys, fires, fairy, and other non-enemies
7774 // based on enemy class b/c guys in dungeons act sort of like enemies
7775 // also easier to manage all the guys this way
7776 2179 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7777 2179 {
7778 2179 mainguy=mg;
7779 2179 canfreeze=false;
7780 2179 dir=down;
7781
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2179 times.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
2179 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7782 2179 hxofs=2;
7783 2179 hzsz=8;
7784 2179 hit_width=12;
7785 2179 hit_height=17;
7786
7787
10/12
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 766 times.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 744 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 277 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 17 times.
✓ Branch 11 taken 260 times.
2179 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7788 {
7789 1919 superman = 1;
7790 1919 hxofs=1000;
7791 1919 }
7792 2179 }
7793
7794 938381 bool guy::animate(int32_t index)
7795 {
7796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 938381 times.
938381 if(switch_hooked) return enemy::animate(index);
7797
6/6
✓ Branch 0 taken 539203 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 8215 times.
✓ Branch 3 taken 530988 times.
✓ Branch 4 taken 7017 times.
✓ Branch 5 taken 1198 times.
938381 if(mainguy && clk==0 && misc==0)
7798 {
7799 1198 setupscreen();
7800 1198 misc = 1;
7801 1198 }
7802
7803
4/4
✓ Branch 0 taken 539203 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 538875 times.
✓ Branch 3 taken 328 times.
938381 if(mainguy && fadeclk==0)
7804 328 return true;
7805
7806 938053 hp=256; // good guys never die...
7807
7808
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 937131 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
938053 if(hclk && !clk2)
7809 {
7810 // but if they get hit...
7811 16 ++clk2; // only do this once
7812
7813
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7814 {
7815 7 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7816 7 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7817 7 }
7818 16 }
7819
7820 938053 return enemy::animate(index);
7821 938381 }
7822
7823 942518 void guy::draw(BITMAP *dest)
7824 {
7825 942518 update_enemy_frame();
7826
7827
6/6
✓ Branch 0 taken 543133 times.
✓ Branch 1 taken 399385 times.
✓ Branch 2 taken 22779 times.
✓ Branch 3 taken 520354 times.
✓ Branch 4 taken 10998 times.
✓ Branch 5 taken 11781 times.
942518 if(!mainguy || fadeclk<0 || fadeclk&1)
7828 930737 enemy::draw(dest);
7829 942518 }
7830
7831 763 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7832 763 {
7833 763 clk4=0;
7834
4/8
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 763 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 763 times.
✗ Branch 7 not taken.
763 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7835 // Spawn type
7836
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 763 times.
763 if(flags & guy_fade_flicker)
7837 {
7838 clk=0;
7839 superman = 1;
7840 fading=fade_flicker;
7841 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7842 dir=down;
7843
7844 if(!canmove(down,(zfix)8,spw_none,false))
7845 clk3=int32_t(13.0/step);
7846 }
7847
3/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 680 times.
✓ Branch 3 taken 83 times.
763 else if(flags & guy_fade_instant)
7848 {
7849 83 clk=0;
7850 83 }
7851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 if (SIZEflags != 0) init_size_flags();;
7852 763 }
7853
7854 167980 bool eFire::animate(int32_t index)
7855 {
7856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167980 times.
167980 if(switch_hooked) return enemy::animate(index);
7857
2/4
✓ Branch 0 taken 167980 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167980 times.
167980 if(fallclk||drownclk) return enemy::animate(index);
7858
2/2
✓ Branch 0 taken 166188 times.
✓ Branch 1 taken 1792 times.
167980 if(fading)
7859 {
7860
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1791 times.
1792 if(++clk4 > 60)
7861 {
7862 1 clk4=0;
7863 1 superman=0;
7864 1 fading=0;
7865
7866
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7867 removearmos(x,y,ffcactivated);
7868
7869 1 clk2=0;
7870
7871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7872 {
7873 1 dir=0;
7874 1 y = y.getInt() & 0xF0;
7875 1 }
7876
7877 1 return Dead(index);
7878 }
7879
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1791 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7880 removearmos(x,y,ffcactivated);
7881 1791 }
7882
7883 167979 return enemy::animate(index);
7884 167980 }
7885
7886 352675 void eFire::draw(BITMAP *dest)
7887 {
7888 352675 update_enemy_frame();
7889 352675 enemy::draw(dest);
7890 352675 }
7891
7892 419 int32_t eFire::takehit(weapon *w, weapon* realweap)
7893 {
7894 419 int32_t wpnId = w->id;
7895 419 int32_t wpnDir = w->dir;
7896
7897
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
419 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7898 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7899 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7900 {
7901 shield = false;
7902 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7903
7904 if(get_qr(qr_BRKNSHLDTILES))
7905 o_tile=s_tile;
7906 }
7907
7908 419 int32_t ret = enemy::takehit(w,realweap);
7909 419 return ret;
7910 }
7911
7912 void eFire::break_shield()
7913 {
7914 if(!shield)
7915 return;
7916
7917 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7918 shield=false;
7919
7920 if(get_qr(qr_BRKNSHLDTILES))
7921 o_tile=s_tile;
7922 }
7923
7924 7314 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7925 7314 {
7926 7314 clk4=0;
7927
4/8
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7314 times.
✗ Branch 7 not taken.
7314 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7928
7929 // Spawn type
7930
2/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7314 times.
7314 if(flags & guy_fade_flicker)
7931 {
7932 clk=0;
7933 superman = 1;
7934 fading=fade_flicker;
7935 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7936 dir=down;
7937
7938 if(!canmove(down,(zfix)8,spw_none,false))
7939 clk3=int32_t(13.0/step);
7940 }
7941
3/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6133 times.
✓ Branch 3 taken 1181 times.
7314 else if(flags & guy_fade_instant)
7942 {
7943 1181 clk=0;
7944 1181 }
7945
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7307 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7314 if (SIZEflags != 0) init_size_flags();;
7946 7314 }
7947
7948 1872314 bool eOther::animate(int32_t index)
7949 {
7950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1872314 times.
1872314 if(switch_hooked) return enemy::animate(index);
7951
3/4
✓ Branch 0 taken 1870797 times.
✓ Branch 1 taken 1517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1870797 times.
1872314 if(fallclk||drownclk) return enemy::animate(index);
7952
2/2
✓ Branch 0 taken 1862383 times.
✓ Branch 1 taken 8414 times.
1870797 if(fading)
7953 {
7954
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 8387 times.
8414 if(++clk4 > 60)
7955 {
7956 27 clk4=0;
7957 27 superman=0;
7958 27 fading=0;
7959
7960
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(flags&guy_armos && z==0 && fakez==0)
7961 removearmos(x,y,ffcactivated);
7962
7963 27 clk2=0;
7964
7965
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!canmove(down,(zfix)8,spw_none,false))
7966 {
7967 2 dir=0;
7968 2 y = y.getInt() & 0xF0;
7969 2 }
7970
7971 27 return Dead(index);
7972 }
7973
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8387 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7974 removearmos(x,y,ffcactivated);
7975 8387 }
7976
7977 1870770 return enemy::animate(index);
7978 1872314 }
7979
7980 1975750 void eOther::draw(BITMAP *dest)
7981 {
7982 1975750 update_enemy_frame();
7983 1975750 enemy::draw(dest);
7984 1975750 }
7985
7986 14188 int32_t eOther::takehit(weapon *w, weapon* realweap)
7987 {
7988 14188 int32_t wpnId = w->id;
7989 14188 int32_t wpnDir = w->dir;
7990
7991
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
14188 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7992 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7993 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7994 {
7995 shield = false;
7996 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7997
7998 if(get_qr(qr_BRKNSHLDTILES))
7999 o_tile=s_tile;
8000 }
8001
8002 14188 int32_t ret = enemy::takehit(w,realweap);
8003 14188 return ret;
8004 }
8005
8006 void eOther::break_shield()
8007 {
8008 if(!shield)
8009 return;
8010
8011 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8012 shield=false;
8013
8014 if(get_qr(qr_BRKNSHLDTILES))
8015 o_tile=s_tile;
8016 }
8017
8018
8019 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8020 {
8021 clk4=0;
8022 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8023
8024 // Spawn type
8025 if(flags & guy_fade_flicker)
8026 {
8027 clk=0;
8028 superman = 1;
8029 fading=fade_flicker;
8030 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8031 dir=down;
8032
8033 if(!canmove(down,(zfix)8,spw_none,false))
8034 clk3=int32_t(13.0/step);
8035 }
8036 else if(flags & guy_fade_instant)
8037 {
8038 clk=0;
8039 }
8040 if (SIZEflags != 0) init_size_flags();;
8041 }
8042
8043 bool eScript::animate(int32_t index)
8044 {
8045 if(switch_hooked) return enemy::animate(index);
8046 if(fallclk||drownclk) return enemy::animate(index);
8047 if(fading)
8048 {
8049 if(++clk4 > 60)
8050 {
8051 clk4=0;
8052 superman=0;
8053 fading=0;
8054
8055 if(flags&guy_armos && z==0 && fakez==0)
8056 removearmos(x,y,ffcactivated);
8057
8058 clk2=0;
8059
8060 if(!canmove(down,(zfix)8,spw_none,false))
8061 {
8062 dir=0;
8063 y = y.getInt() & 0xF0;
8064 }
8065
8066 return Dead(index);
8067 }
8068 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8069 removearmos(x,y,ffcactivated);
8070 }
8071
8072 return enemy::animate(index);
8073 }
8074
8075 void eScript::draw(BITMAP *dest)
8076 {
8077 update_enemy_frame();
8078 enemy::draw(dest);
8079 }
8080
8081 int32_t eScript::takehit(weapon *w, weapon* realweap)
8082 {
8083 int32_t wpnId = w->id;
8084 int32_t wpnDir = w->dir;
8085
8086 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8087 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8088 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8089 {
8090 shield = false;
8091 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8092
8093 if(get_qr(qr_BRKNSHLDTILES))
8094 o_tile=s_tile;
8095 }
8096
8097 int32_t ret = enemy::takehit(w,realweap);
8098 return ret;
8099 }
8100
8101 void eScript::break_shield()
8102 {
8103 if(!shield)
8104 return;
8105
8106 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8107 shield=false;
8108
8109 if(get_qr(qr_BRKNSHLDTILES))
8110 o_tile=s_tile;
8111 }
8112
8113
8114 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8115 {
8116 clk4=0;
8117 hyofs = -32768; //No hitbox initially.
8118 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8119
8120 // Spawn type
8121 if(flags & guy_fade_flicker)
8122 {
8123 clk=0;
8124 superman = 1;
8125 fading=fade_flicker;
8126 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8127 dir=down;
8128
8129 if(!canmove(down,(zfix)8,spw_none,false))
8130 clk3=int32_t(13.0/step);
8131 }
8132 else if(flags & guy_fade_instant)
8133 {
8134 clk=0;
8135 }
8136 if (SIZEflags != 0) init_size_flags();;
8137 }
8138
8139 bool eFriendly::animate(int32_t index)
8140 {
8141 if(switch_hooked) return enemy::animate(index);
8142 if(fallclk||drownclk) return enemy::animate(index);
8143 if(fading)
8144 {
8145 if(++clk4 > 60)
8146 {
8147 clk4=0;
8148 superman=0;
8149 fading=0;
8150
8151 if(flags&guy_armos && z==0 && fakez==0)
8152 removearmos(x,y,ffcactivated);
8153
8154 clk2=0;
8155
8156 if(!canmove(down,(zfix)8,spw_none,false))
8157 {
8158 dir=0;
8159 y = y.getInt() & 0xF0;
8160 }
8161
8162 return Dead(index);
8163 }
8164 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8165 removearmos(x,y,ffcactivated);
8166 }
8167
8168 return enemy::animate(index);
8169 }
8170
8171 void eFriendly::draw(BITMAP *dest)
8172 {
8173 update_enemy_frame();
8174 enemy::draw(dest);
8175 }
8176
8177 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8178 {
8179 int32_t wpnId = w->id;
8180 int32_t wpnDir = w->dir;
8181
8182 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8183 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8184 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8185 {
8186 shield = false;
8187 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8188
8189 if(get_qr(qr_BRKNSHLDTILES))
8190 o_tile=s_tile;
8191 }
8192
8193 int32_t ret = enemy::takehit(w,realweap);
8194 return ret;
8195 }
8196
8197 void eFriendly::break_shield()
8198 {
8199 if(!shield)
8200 return;
8201
8202 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8203 shield=false;
8204
8205 if(get_qr(qr_BRKNSHLDTILES))
8206 o_tile=s_tile;
8207 }
8208
8209
8210 779127 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8211 {
8212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779127 times.
779127 if (ffcactive)
8213 {
8214 removearmosffc(ffcactive-1);
8215 return;
8216 }
8217
2/2
✓ Branch 0 taken 778147 times.
✓ Branch 1 taken 980 times.
779127 if(did_armos)
8218 {
8219 778147 return;
8220 }
8221
8222 980 did_armos=true;
8223 980 ax&=0xF0;
8224 980 ay&=0xF0;
8225 980 int32_t cd = (ax>>4)+ay;
8226 980 int32_t f = MAPFLAG(ax,ay);
8227 980 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8228
8229
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 140 times.
980 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8230 {
8231 840 return;
8232 }
8233
8234 140 tmpscr->data[cd] = tmpscr->undercombo;
8235 140 tmpscr->cset[cd] = tmpscr->undercset;
8236 140 tmpscr->sflag[cd] = 0;
8237
8238
3/4
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 118 times.
140 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8239 {
8240 22 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8241 22 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8242 22 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8243 22 sfx(tmpscr->secretsfx);
8244 22 }
8245
8246
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
140 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8247 {
8248
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8249 {
8250 3 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8251 3 sfx(tmpscr->secretsfx);
8252 3 }
8253 3 }
8254
8255 140 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8256 779127 }
8257
8258 void enemy::removearmosffc(int32_t pos)
8259 {
8260 if(did_armos)
8261 {
8262 return;
8263 }
8264
8265 did_armos=true;
8266 ffcdata& ffc = tmpscr->ffcs[pos];
8267 newcombo const& cmb = combobuf[ffc.data];
8268 int32_t f2 = cmb.flag;
8269
8270 if(cmb.type!=cARMOS)
8271 {
8272 return;
8273 }
8274
8275 zc_ffc_set(ffc, tmpscr->undercombo);
8276 ffc.cset = tmpscr->undercset;
8277
8278 if(f2 == mfARMOS_SECRET)
8279 {
8280 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8281 ffc.cset = tmpscr->secretcset[sSTAIRS];
8282 sfx(tmpscr->secretsfx);
8283 }
8284
8285 if(f2 == mfARMOS_ITEM)
8286 {
8287 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8288 {
8289 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8290 sfx(tmpscr->secretsfx);
8291 }
8292 }
8293
8294 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8295 }
8296
8297
8298 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8299 461 {
8300 461 fading=fade_flicker;
8301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8302 461 dir=12;
8303 461 movestatus=1;
8304
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8305 461 clk=0;
8306 461 clk4=0;
8307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8308 461 }
8309
8310 117025 bool eGhini::animate(int32_t index)
8311 {
8312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8313
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8314
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8315 50 return Dead(index);
8316
8317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8318 {
8319
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8320 {
8321
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8322 54853 misc=2;
8323
8324
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8325 89752 removearmos(x,y,ffcactivated);
8326 89752 }
8327
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8328 {
8329 425 misc=1;
8330 425 clk3=32;
8331 425 fading=0;
8332
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (ffcactivated > 0)
8333 {
8334 guygridffc[ffcactivated-1] = 0;
8335 removearmosffc(ffcactivated-1);
8336 }
8337 else
8338 {
8339 425 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8340 425 removearmos(x,y);
8341 }
8342 425 }
8343 116975 }
8344
8345 116975 clk4++;
8346
8347 116975 return enemy::animate(index);
8348 117025 }
8349
8350 238808 void eGhini::draw(BITMAP *dest)
8351 {
8352 238808 update_enemy_frame();
8353 238808 enemy::draw(dest);
8354 238808 }
8355
8356 2 void eGhini::kickbucket()
8357 {
8358 2 hp=-1000; // don't call death_sfx()
8359 2 }
8360
8361
2/4
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
10392 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8362 5196 {
8363
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 old_y=y;
8364 5196 dir=down;
8365 5196 misc=1;
8366 5196 clk=-15;
8367
8368
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 2551 times.
5196 if(!BSZ)
8369
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 clk*=zc_oldrand()%3+1;
8370
8371 // avoid divide by 0 errors
8372
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc1 == 0)
8373 dmisc1 = 24;
8374
8375
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc2 == 0)
8376 dmisc2 = 3;
8377
8378 //nets+760;
8379
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if (SIZEflags != 0) init_size_flags();;
8380 5196 }
8381
8382 1435270 bool eTektite::animate(int32_t index)
8383 {
8384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435270 times.
1435270 if(switch_hooked) return enemy::animate(index);
8385
4/4
✓ Branch 0 taken 1426328 times.
✓ Branch 1 taken 8942 times.
✓ Branch 2 taken 8942 times.
✓ Branch 3 taken 1423910 times.
1435270 if(fallclk||drownclk) return enemy::animate(index);
8386
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1397243 times.
1423910 if(dying)
8387 26667 return Dead(index);
8388
8389
2/2
✓ Branch 0 taken 1360175 times.
✓ Branch 1 taken 37068 times.
1397243 if(clk==0)
8390 {
8391 37068 removearmos(x,y,ffcactivated);
8392 37068 }
8393
8394
2/2
✓ Branch 0 taken 1056060 times.
✓ Branch 1 taken 341183 times.
1397243 if(get_qr(qr_ENEMIESZAXIS))
8395 {
8396 341183 y=floor_y;
8397 341183 }
8398
8399
9/10
✓ Branch 0 taken 1282576 times.
✓ Branch 1 taken 114667 times.
✓ Branch 2 taken 1269012 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1269012 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1257836 times.
✓ Branch 8 taken 11976 times.
✓ Branch 9 taken 21878 times.
1397243 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8400 {
8401
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421148 times.
✓ Branch 2 taken 344884 times.
✓ Branch 3 taken 493422 times.
1279714 switch(misc)
8402 {
8403 case 0: // normal
8404
2/2
✓ Branch 0 taken 409927 times.
✓ Branch 1 taken 11221 times.
421148 if(!(zc_oldrand()%dmisc1))
8405 {
8406 11221 misc=1;
8407 11221 clk2=32;
8408 11221 }
8409
8410 421148 break;
8411
8412 case 1: // waiting to pounce
8413
2/2
✓ Branch 0 taken 324265 times.
✓ Branch 1 taken 20619 times.
344884 if(--clk2<=0)
8414 {
8415 20619 int32_t r=zc_oldrand();
8416 20619 misc=2;
8417 20619 step=0-(zslongToFix(dstep*100)); // initial speed
8418 20619 clk3=(r&1)+2; // left or right
8419 20619 clk2start=clk2=(r&31)+10; // flight time
8420
8421
2/2
✓ Branch 0 taken 18196 times.
✓ Branch 1 taken 2423 times.
20619 if(y<32) clk2+=2; // make them come down from top of screen
8422
8423
2/2
✓ Branch 0 taken 15702 times.
✓ Branch 1 taken 4917 times.
20619 if(y>112) clk2-=2; // make them go back up
8424
8425 20619 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8426 20619 }
8427
8428 344884 break;
8429
8430 case 2: // in flight
8431 493422 move(step);
8432
8433
2/2
✓ Branch 0 taken 234221 times.
✓ Branch 1 taken 259201 times.
493422 if(step>0) //going down
8434 {
8435
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233589 times.
234221 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8436 {
8437 632 step=0-step;
8438 632 }
8439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8440 {
8441 step=0-step;
8442 }
8443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(ispitfall(x+8,y+16))
8444 {
8445 step=0-step;
8446 }
8447
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233542 times.
233589 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8448 {
8449 47 step=0-step;
8450 47 }
8451
2/2
✓ Branch 0 taken 233531 times.
✓ Branch 1 taken 11 times.
233542 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8452 {
8453 11 step=0-step;
8454 11 }
8455 234221 }
8456
2/2
✓ Branch 0 taken 15154 times.
✓ Branch 1 taken 244047 times.
259201 else if(step<0)
8457 {
8458
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243609 times.
244047 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8459 {
8460 438 step=0-step;
8461 438 }
8462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8463 {
8464 step=0-step;
8465 }
8466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(ispitfall(x+8,y))
8467 {
8468 step=0-step;
8469 }
8470
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243588 times.
243609 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8471 {
8472 21 step=0-step;
8473 21 }
8474
2/2
✓ Branch 0 taken 243569 times.
✓ Branch 1 taken 19 times.
243588 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8475 {
8476 19 step=0-step;
8477 19 }
8478 244047 }
8479
8480
2/2
✓ Branch 0 taken 244152 times.
✓ Branch 1 taken 249270 times.
493422 if(clk3==left)
8481 {
8482
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 243877 times.
244152 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8483 {
8484 275 clk3^=1;
8485 275 }
8486
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 243871 times.
243877 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8487 {
8488 6 clk3^=1;
8489 6 }
8490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243871 times.
243871 else if(ispitfall(x,y+8))
8491 {
8492 clk3^=1;
8493 }
8494
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 243841 times.
243871 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8495 {
8496 30 clk3^=1;
8497 30 }
8498
2/2
✓ Branch 0 taken 243829 times.
✓ Branch 1 taken 12 times.
243841 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8499 {
8500 12 clk3^=1;
8501 12 }
8502 244152 }
8503 else
8504 {
8505
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 248994 times.
249270 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8506 {
8507 276 clk3^=1;
8508 276 }
8509
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 248982 times.
248994 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8510 {
8511 12 clk3^=1;
8512 12 }
8513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248982 times.
248982 else if(ispitfall(x+16,y+8))
8514 {
8515 clk3^=1;
8516 }
8517
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 248977 times.
248982 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8518 {
8519 5 clk3^=1;
8520 5 }
8521
2/2
✓ Branch 0 taken 248965 times.
✓ Branch 1 taken 12 times.
248977 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8522 {
8523 12 clk3^=1;
8524 12 }
8525 }
8526
8527 493422 --c;
8528
8529
4/4
✓ Branch 0 taken 151408 times.
✓ Branch 1 taken 342014 times.
✓ Branch 2 taken 320475 times.
✓ Branch 3 taken 172947 times.
493422 if(c<0 && step<zslongToFix(dstep*100))
8530 {
8531 172947 step+=zslongToFix(dmisc3*100);
8532 172947 }
8533
8534 493422 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8535
8536
2/2
✓ Branch 0 taken 492701 times.
✓ Branch 1 taken 721 times.
493422 if(x<=16-nb) clk3=right;
8537
8538
2/2
✓ Branch 0 taken 492430 times.
✓ Branch 1 taken 992 times.
493422 if(x>=224+nb) clk3=left;
8539
8540 493422 x += (clk3==left) ? -1 : 1;
8541
8542
4/4
✓ Branch 0 taken 29025 times.
✓ Branch 1 taken 464397 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454267 times.
493422 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8543 {
8544
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17274 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39155 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8545 {
8546 185 step=0-step;
8547 185 y--;
8548 185 }
8549
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 12916 times.
18710 else if(zc_oldrand()%dmisc2) //land and wait
8550 {
8551 12916 clk=misc=0;
8552 12916 } //land and jump again
8553 else
8554 {
8555 5794 misc=1;
8556 5794 clk2=0;
8557 }
8558 18895 }
8559
8560 473162 break;
8561 } // switch
8562 1259454 }
8563
8564
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1058478 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1399661 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8565 {
8566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8567 {
8568 int32_t tempy = floor_y;
8569 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8570 floor_y = y;
8571 y=tempy-fakez;
8572 old_y = y;
8573 }
8574 else
8575 {
8576 109977 int32_t tempy = floor_y;
8577
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8578 109977 floor_y = y;
8579 109977 y=tempy-z;
8580 109977 old_y = y;
8581 }
8582 109977 }
8583
8584
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1386097 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1399661 if(stunclk && (clk&31)==1)
8585 10637 clk=0;
8586
8587 1399661 return enemy::animate(index);
8588 1426328 }
8589
8590 803206 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8591 {
8592
5/6
✓ Branch 0 taken 625928 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 625928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600737 times.
✓ Branch 5 taken 25191 times.
803206 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8593 25191 return;
8594
8595 778015 int32_t tempy=yofs;
8596 778015 int32_t fdiv = frate/4;
8597
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8598
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8599 778015 efrate:((clk>=(frate>>1))?1:0);
8600 778015 flip = 0;
8601 778015 shadowtile = wpnsbuf[spr_shadow].tile;
8602
8603
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 if(get_qr(qr_NEWENEMYTILES))
8604 {
8605
2/2
✓ Branch 0 taken 575932 times.
✓ Branch 1 taken 202083 times.
778015 if(misc==0)
8606 {
8607 202083 shadowtile+=f2;
8608 202083 }
8609
2/2
✓ Branch 0 taken 254903 times.
✓ Branch 1 taken 321029 times.
575932 else if(misc!=1)
8610 321029 shadowtile+=2;
8611 778015 }
8612 else
8613 {
8614 if(misc==0)
8615 {
8616 shadowtile += f2 ? 1 : 0;
8617 }
8618 else if(misc!=1)
8619 {
8620 ++shadowtile;
8621 }
8622 }
8623
8624 778015 yofs+=8;
8625
8626
4/4
✓ Branch 0 taken 600737 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 339908 times.
✓ Branch 3 taken 260829 times.
778015 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8627 {
8628
6/6
✓ Branch 0 taken 134073 times.
✓ Branch 1 taken 126756 times.
✓ Branch 2 taken 243385 times.
✓ Branch 3 taken 17444 times.
✓ Branch 4 taken 123475 times.
✓ Branch 5 taken 119910 times.
260829 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8629 260829 }
8630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 778015 times.
778015 if(!shadow_overpit(this))
8631 778015 enemy::drawshadow(dest,translucent);
8632 778015 yofs=tempy;
8633 803206 }
8634
8635 2045360 void eTektite::draw(BITMAP *dest)
8636 {
8637 2045360 update_enemy_frame();
8638 2045360 enemy::draw(dest);
8639 2045360 }
8640
8641 730 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8642 730 {
8643
2/4
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
730 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8644 730 superman=1;
8645 730 dir=8;
8646 730 hxofs=1000;
8647 730 mainguy=false;
8648 730 count_enemy=false;
8649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if (SIZEflags != 0) init_size_flags();;
8650 730 }
8651
8652 279897 bool eItemFairy::animate(int32_t index)
8653 {
8654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(switch_hooked) return enemy::animate(index);
8655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(dying)
8656 return Dead(index);
8657
8658 //if(clk>32)
8659 279897 misc=1;
8660 279897 bool w=watch;
8661 279897 watch=false;
8662 279897 variable_walk_8(misc?3:0,0,8,spw_floater);
8663 279897 watch=w;
8664
8665
2/2
✓ Branch 0 taken 1514 times.
✓ Branch 1 taken 278383 times.
279897 if(clk==0)
8666 {
8667 1514 removearmos(x,y,ffcactivated);
8668 1514 }
8669
8670 279897 return enemy::animate(index);
8671 279897 }
8672
8673 562150 void eItemFairy::draw(BITMAP *dest)
8674 {
8675 //these are here to bypass compiler warnings about unused arguments
8676 562150 dest=dest;
8677 562150 }
8678
8679 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8680 1825 {
8681 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8682
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8683 1825 dir=8;
8684 1825 movestatus=1;
8685 1825 clk=0;
8686
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8687 //nets+720;
8688
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8689 1825 }
8690
8691 520615 bool ePeahat::animate(int32_t index)
8692 {
8693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8694
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8695
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8696 {
8697 78 return false;
8698 }
8699
8700
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8701 1030 return Dead(index);
8702
8703
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8704 {
8705 3083 removearmos(x,y,ffcactivated);
8706 3083 }
8707
8708
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8709 263053 misc=1;
8710
8711
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8712
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8713
8714
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8715 {
8716
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8717 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8718 100018 }
8719
8720
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8721 1634 superman=0;
8722 else
8723
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8724 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8725
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8726 {
8727
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8728 264937 }
8729 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8730 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8731
8732
8733
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8734
8735 519507 return enemy::animate(index);
8736 520615 }
8737
8738 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8739 {
8740 334520 int32_t tempy=yofs;
8741 334520 flip = 0;
8742 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8743
8744
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8745 {
8746 246431 yofs+=8;
8747 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8748 246431 }
8749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8750 334520 enemy::drawshadow(dest,translucent);
8751 334520 yofs=tempy;
8752 334520 }
8753
8754 1144330 void ePeahat::draw(BITMAP *dest)
8755 {
8756 1144330 update_enemy_frame();
8757 1144330 enemy::draw(dest);
8758 1144330 }
8759
8760 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8761 {
8762 4136 int32_t wpnId = w->id;
8763 4136 int32_t enemyHitWeapon = w->parentitem;
8764
8765
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8766 return 0;
8767
8768
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8769 // fire boomerang, for nailing peahats
8770
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8771 3343 return 0;
8772
8773 // Time for a kludge...
8774 793 int32_t s = superman;
8775 793 superman = 0;
8776 793 int32_t ret = enemy::takehit(w,realweap);
8777 793 superman = s;
8778
8779 // Anyway...
8780
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8781 {
8782 192 clk2=0;
8783 192 movestatus=0;
8784 192 misc=0;
8785 192 clk=0;
8786 192 step=0;
8787 192 }
8788
8789 793 return ret;
8790 4136 }
8791
8792 // auomatically kill off enemy (for rooms with ringleaders)
8793 void ePeahat::kickbucket()
8794 {
8795 hp=-1000; // don't call death_sfx()
8796 }
8797
8798 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8799 3942 {
8800 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8801
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8802 {
8803 2147 misc=-1; //Line of Sight leevers
8804 2147 clk-=16;
8805 2147 }
8806 3942 clk3 = 0;
8807 //nets+1460;
8808 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8809 3942 submerged = false;
8810
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8811 3942 }
8812
8813 923 bool eLeever::isSubmerged() const
8814 {
8815 923 Z_scripterrlog("misc is: %d\n", misc);
8816 923 return misc <= 0;
8817
8818 }
8819
8820 1018478 bool eLeever::animate(int32_t index)
8821 {
8822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8823
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8824 {
8825 355 return enemy::animate(index);
8826 }
8827
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8828 31552 return Dead(index);
8829
8830
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8831 {
8832 44970 removearmos(x,y,ffcactivated);
8833 44970 }
8834
8835
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8836 {
8837 // switch(d->misc1)
8838
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8839 {
8840 case 0: //line of sight
8841 case 2:
8842
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8843 {
8844 case -1: //submerged
8845 {
8846
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8847
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8848 {
8849 10261 break;
8850 }
8851
8852 114198 int32_t active=0;
8853
8854
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8855 {
8856
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8857 {
8858 225696 ++active;
8859 225696 }
8860 783342 }
8861
8862
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8863 {
8864 1871 misc=0; //activate this one
8865 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8866 1871 }
8867 }
8868 114198 break;
8869
8870 case 0:
8871 {
8872
8873
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8874 {
8875 misc=1;
8876 clk2=0;
8877 }
8878
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8879 {
8880 57 misc = -1;
8881 57 break;
8882 }
8883 49052 int32_t s=0;
8884
8885
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8886 {
8887
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8888 {
8889 7882 ++s;
8890 7882 }
8891 273250 }
8892
8893
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8894 {
8895 7882 break;
8896 }
8897
8898 41170 int32_t d2=zc_oldrand()&1;
8899
8900
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8901 {
8902 26661 d2+=2;
8903 26661 }
8904
8905
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 662 times.
✓ Branch 3 taken 39060 times.
41170 if(canplace(d2) || canplace(d2^1))
8906 {
8907 2110 misc=1;
8908 2110 clk2=0;
8909 2110 clk=0;
8910 2110 }
8911 }
8912 41170 break;
8913
8914 case 1:
8915
8916
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8917
8918 35464 break;
8919
8920 case 2:
8921
8922
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8923
8924 15780 break;
8925
8926 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8927 case 3:
8928
8929
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
8930
8931
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
8932
8933
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
8934 94963 else move(zslongToFix(dstep*100));
8935
8936 95468 break;
8937
8938 case 4:
8939
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
8940
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
8941 {
8942 468 misc=5;
8943 468 clk=8;
8944 468 }
8945
8946 4365 break;
8947
8948 case 5:
8949
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
8950
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
8951
8952 6907 break;
8953 } // switch(misc)
8954
8955 337868 break;
8956
8957 default: //random
8958 // step=d->misc3/100.0;
8959
8960 473814 step=zslongToFix(dmisc3*100);
8961
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
8962 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8963 {
8964 if (clk2 < 48) clk2+=2;
8965 if (clk2 >= 300) clk2-=2;
8966 }
8967
8968
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
8969
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
8970
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
8971 {
8972 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
8973 {
8974 fix_coords();
8975 }*/
8976 289541 misc=3;
8977 289541 step = zslongToFix(dstep*100);
8978 289541 }
8979
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
8980
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
8981
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
8982 {
8983 40151 misc=0;
8984 40151 step=0;
8985 40151 }
8986 274 else clk2=0;
8987
8988
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
8989
8990 // variable_walk(d->rate, d->homing, 0);
8991 473814 variable_walk(rate, homing, 0);
8992 473814 } // switch(dmisc1)
8993 811682 }
8994
8995 986571 hxofs=(misc>=2)?0:1000;
8996 986571 return enemy::animate(index);
8997 1018478 }
8998
8999 80892 bool eLeever::canplace(int32_t d2)
9000 {
9001 80892 int32_t nx=HeroX();
9002 80892 int32_t ny=HeroY();
9003
9004
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny&=0xF0;
9005 52400 else nx&=0xF0;
9006
9007
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9008 {
9009 // case up: ny-=((d->misc1==0)?32:48); break;
9010 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9011 // case left: nx-=((d->misc1==0)?32:48); break;
9012 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9013 case up:
9014
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9015 14174 break;
9016
9017 case down:
9018
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9019
9020
4/4
✓ Branch 0 taken 10086 times.
✓ Branch 1 taken 4232 times.
✓ Branch 2 taken 10075 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9021
9022 14318 break;
9023
9024 case left:
9025
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9026 26181 break;
9027
9028 case right:
9029
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9030
9031
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9032
9033 26219 break;
9034 }
9035
9036
4/4
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 60464 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11427 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9037 69465 return false;
9038
9039
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 10563 times.
11427 if(d2>=left)
9040
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9041 9317 return false;
9042
9043 2110 x=nx;
9044 2110 y=ny;
9045 2110 dir=d2^1;
9046 2110 return true;
9047 80892 }
9048
9049 1024382 void eLeever::draw(BITMAP *dest)
9050 {
9051 // cs=d->cset;
9052 1024382 cs=dcset;
9053 1024382 update_enemy_frame();
9054
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9055 {
9056
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9057 {
9058 case -1:
9059 case 0:
9060 386939 return;
9061 }
9062 637088 }
9063
9064 637443 enemy::draw(dest);
9065 1024382 }
9066
9067 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9068 998 {
9069 998 hashero=false;
9070 //nets+1000;
9071
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9072 998 }
9073
9074 504762 bool eWallM::animate(int32_t index)
9075 {
9076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9077
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9078 {
9079 return enemy::animate(index);
9080 }
9081
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9082 9856 return Dead(index);
9083
9084
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9085 {
9086 30976 removearmos(x,y,ffcactivated);
9087 30976 }
9088
9089 494906 hxofs=1000;
9090
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9091 {
9092
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9093 {
9094 211789 int32_t wall=hero_on_wall();
9095 211789 int32_t wallm_cnt=0;
9096
9097
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9098
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9099 {
9100 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9101
9102
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9103 {
9104 13366 ++wallm_cnt;
9105 13366 }
9106 1013091 }
9107
9108
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9109 {
9110 841 --wall;
9111 841 misc=1; //emerging from the wall?
9112 841 clk2=0;
9113 841 clk3=wall^1;
9114 841 wallm_load_clk=frame;
9115
9116
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9117 {
9118
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9119 91 dir=right;
9120 else
9121 423 dir=left;
9122 514 }
9123 else
9124 {
9125
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9126 66 dir=down;
9127 else
9128 261 dir=up;
9129 }
9130
9131
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9132 {
9133 case up:
9134 231 y=0;
9135 231 break;
9136
9137 case down:
9138 283 y=160;
9139 283 break;
9140
9141 case left:
9142 223 x=0;
9143 223 break;
9144
9145 case right:
9146 104 x=240;
9147 104 break;
9148 }
9149
9150
9151
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9152 {
9153 case up:
9154 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9155 261 flip=wall&1;
9156 261 break;
9157
9158 case down:
9159 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9160 66 flip=((wall&1)^1)+2;
9161 66 break;
9162
9163 case left:
9164 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9165 423 flip=(wall==up?2:0)+1;
9166 423 break;
9167
9168 case right:
9169 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9170 91 flip=(wall==up?2:0);
9171 91 break;
9172 }
9173
9174 841 }
9175 211789 }
9176 377174 }
9177 else
9178 117732 wallm_crawl();
9179
9180 494906 return enemy::animate(index);
9181 504762 }
9182
9183 117732 void eWallM::wallm_crawl()
9184 {
9185 117732 bool w=watch;
9186 117732 hxofs=0;
9187
9188
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9189 {
9190 810 return;
9191 }
9192
9193 // if(dying || watch || (!hashero && stunclk))
9194
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9195 {
9196 14546 return;
9197 }
9198
9199 102376 watch=false;
9200 102376 ++clk2;
9201 // Misc1: slightly different movement
9202 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9203
9204 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9206
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9207 {
9208 4491 --clk2;
9209 4491 }
9210
9211
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9212 {
9213 case 1:
9214 case 2:
9215 52852 zc_swap(dir,clk3);
9216 52852 move(step);
9217 52852 zc_swap(dir,clk3);
9218 52852 break;
9219
9220 case 3:
9221 case 4:
9222 case 5:
9223
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9224 {
9225 4491 watch=w;
9226 4491 return;
9227 }
9228
9229 34905 move(step);
9230 34905 break;
9231
9232 case 6:
9233 case 7:
9234 9984 zc_swap(dir,clk3);
9235 9984 dir^=1;
9236 9984 move(step);
9237 9984 dir^=1;
9238 9984 zc_swap(dir,clk3);
9239 9984 break;
9240
9241 default:
9242 144 misc=0;
9243 144 break;
9244 }
9245
9246 97885 watch=w;
9247 117732 }
9248
9249 9 void eWallM::grabhero()
9250 {
9251 9 hashero=true;
9252 9 superman=1;
9253 9 }
9254
9255 507147 void eWallM::draw(BITMAP *dest)
9256 {
9257 507147 dummy_bool[1]=hashero;
9258 507147 update_enemy_frame();
9259
9260
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9261 {
9262 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9263 129181 }
9264
9265 // enemy::draw(dest);
9266 // tile = clk&8 ? 128:129;
9267 507147 }
9268
9269 bool eWallM::isSubmerged() const
9270 {
9271 return ( !misc );
9272 }
9273
9274 1600 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9275 1600 {
9276
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 ox=x; //original x
9277
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 oy=y; //original y
9278
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 126 times.
1600 if(get_qr(qr_TRAPPOSFIX))
9279 {
9280
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9281 126 }
9282
9283 1600 mainguy=false;
9284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9285 //nets+420;
9286 1600 dummy_int[1]=0;
9287
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if (SIZEflags != 0) init_size_flags();;
9288 1600 }
9289
9290 1036935 bool eTrap::animate(int32_t index)
9291 {
9292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1036935 times.
1036935 if(switch_hooked) return enemy::animate(index);
9293
2/4
✓ Branch 0 taken 1036935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1036935 times.
1036935 if(fallclk||drownclk) return enemy::animate(index);
9294
2/2
✓ Branch 0 taken 1015341 times.
✓ Branch 1 taken 21594 times.
1036935 if(clk<0)
9295 21594 return enemy::animate(index);
9296
9297
2/2
✓ Branch 0 taken 951124 times.
✓ Branch 1 taken 64217 times.
1015341 if(clk==0)
9298 {
9299 64217 removearmos(x,y,ffcactivated);
9300 64217 }
9301
9302
2/2
✓ Branch 0 taken 317997 times.
✓ Branch 1 taken 697344 times.
1015341 if(misc==0) // waiting
9303 {
9304 697344 ox = x;
9305 697344 oy = y;
9306 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9307 697344 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9308
9309
4/4
✓ Branch 0 taken 240663 times.
✓ Branch 1 taken 456681 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 107487 times.
697344 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9310 {
9311 107487 dir=down;
9312 107487 }
9313
4/4
✓ Branch 0 taken 391518 times.
✓ Branch 1 taken 198339 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 258342 times.
589857 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9314 {
9315 258342 dir=right;
9316 258342 }
9317
4/4
✓ Branch 0 taken 210645 times.
✓ Branch 1 taken 120870 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 77469 times.
331515 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9318 {
9319 77469 dir=up;
9320 77469 }
9321 else
9322 {
9323 254046 dir=left;
9324 }
9325
9326 697344 int32_t d2=lined_up(15,true);
9327
9328
4/4
✓ Branch 0 taken 267045 times.
✓ Branch 1 taken 430299 times.
✓ Branch 2 taken 1111152 times.
✓ Branch 3 taken 413808 times.
1091329 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9329
2/2
✓ Branch 0 taken 232556 times.
✓ Branch 1 taken 190596 times.
413808 ((d2>down) && (dmisc1==2)) ||
9330
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 60611 times.
190596 ((d2>right) && (!dmisc1)) ||
9331
2/2
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
247680 ((d2<l_up) && (dmisc1==4)) ||
9332
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 247680 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
146305 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9333
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
247680 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9334 {
9335 2525663 d2=-1;
9336 2525663 }
9337
9338
4/4
✓ Branch 0 taken 20700 times.
✓ Branch 1 taken 428964 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2107 times.
449664 if(d2!=-1 && trapmove(d2))
9339 {
9340 2107 dir=d2;
9341 2107 misc=1;
9342 2107 clk2=(dir==down)?3:0;
9343 2107 }
9344 449664 }
9345
9346
2/2
✓ Branch 0 taken 678404 times.
✓ Branch 1 taken 89257 times.
767661 if(misc==1) // charging
9347 {
9348 89257 clk2=(clk2+1)&3;
9349 89257 step=(clk2==3)?1:2;
9350
9351
4/4
✓ Branch 0 taken 88461 times.
✓ Branch 1 taken 796 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87356 times.
89257 if(!trapmove(dir) || clip())
9352 {
9353 1901 misc=2;
9354
9355
1/2
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
1901 if(dir<l_up)
9356 {
9357 1901 dir=dir^1;
9358 1901 }
9359 else
9360 {
9361 dir=dir^3;
9362 }
9363 1901 }
9364 else
9365 {
9366 87356 sprite::move(step);
9367 }
9368 89257 }
9369
9370
2/2
✓ Branch 0 taken 534913 times.
✓ Branch 1 taken 232748 times.
767661 if(misc==2) // retreating
9371 {
9372 232748 step=(++clk2&1)?1:0;
9373
9374
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80505 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84103 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
232748 switch(dir)
9375 {
9376 case up:
9377
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9378 38739 else sprite::move(step);
9379
9380 38739 break;
9381
9382 case left:
9383
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 80117 times.
80505 if(int32_t(x)<=ox) goto trap_rest;
9384 80117 else sprite::move(step);
9385
9386 80117 break;
9387
9388 case down:
9389
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9390 28905 else sprite::move(step);
9391
9392 28905 break;
9393
9394 case right:
9395
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 83672 times.
84103 if(int32_t(x)>=ox) goto trap_rest;
9396 83672 else sprite::move(step);
9397
9398 83672 break;
9399
9400 case l_up:
9401 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9402 else sprite::move(step);
9403
9404 break;
9405
9406 case r_up:
9407 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9408 else sprite::move(step);
9409
9410 break;
9411
9412 case l_down:
9413 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9414 else sprite::move(step);
9415
9416 break;
9417
9418 case r_down:
9419 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9420 else sprite::move(step);
9421
9422 break;
9423 trap_rest:
9424 {
9425 1315 x=ox;
9426 1315 y=oy;
9427 1315 misc=0;
9428 }
9429 1315 }
9430 232748 }
9431
9432 767661 return enemy::animate(index);
9433 789255 }
9434
9435 109957 bool eTrap::trapmove(int32_t ndir)
9436 {
9437
2/2
✓ Branch 0 taken 80193 times.
✓ Branch 1 taken 29764 times.
109957 if(get_qr(qr_MEANTRAPS))
9438 {
9439
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 78853 times.
80193 if(tmpscr->flags2&fFLOATTRAPS)
9440 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9441
9442 78853 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9443 }
9444
9445
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9446 4730 return false;
9447
9448
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9449 return false;
9450
9451
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9452 return false;
9453
9454
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9455 return false;
9456
9457
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9458 4722 return false;
9459
9460
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9461 713 return false;
9462
9463
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9464 return false;
9465
9466
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9467 return false;
9468
9469
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9470 return false;
9471
9472
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9473 return false;
9474
9475 19599 return true;
9476 109957 }
9477
9478 88461 bool eTrap::clip()
9479 {
9480
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45439 times.
88461 if(get_qr(qr_MEANPLACEDTRAPS))
9481 {
9482
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 15895 times.
✓ Branch 4 taken 15096 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45439 switch(dir)
9483 {
9484 case up:
9485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9486
9487 5792 break;
9488
9489 case down:
9490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=160) return true;
9491
9492 8656 break;
9493
9494 case left:
9495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15895 times.
15895 if(x<=0) return true;
9496
9497 15895 break;
9498
9499 case right:
9500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15096 times.
15096 if(x>=240) return true;
9501
9502 15096 break;
9503
9504 case l_up:
9505 if(y<=0||x<=0) return true;
9506
9507 break;
9508
9509 case l_down:
9510 if(y>=160||x<=0) return true;
9511
9512 break;
9513
9514 case r_up:
9515 if(y<=0||x>=240) return true;
9516
9517 break;
9518
9519 case r_down:
9520 if(y>=160||x>=240) return true;
9521
9522 break;
9523 }
9524
9525 45439 return false;
9526 }
9527 else
9528 {
9529
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9530 {
9531 case up:
9532
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9533
9534 4695 break;
9535
9536 case down:
9537
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9538
9539 5253 break;
9540
9541 case left:
9542
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9543
9544 16376 break;
9545
9546 case right:
9547
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9548
9549 15593 break;
9550
9551 case l_up:
9552 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9553
9554 break;
9555
9556 case l_down:
9557 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9558
9559 break;
9560
9561 case r_up:
9562 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9563
9564 break;
9565
9566 case r_down:
9567 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9568
9569 break;
9570 }
9571
9572 41917 return false;
9573 }
9574 88461 }
9575
9576 1043991 void eTrap::draw(BITMAP *dest)
9577 {
9578 1043991 update_enemy_frame();
9579 1043991 enemy::draw(dest);
9580 1043991 }
9581
9582 5705 int32_t eTrap::takehit(weapon*,weapon*)
9583 {
9584 5705 return 0;
9585 }
9586
9587 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9588 832 {
9589 832 lasthit=-1;
9590 832 lasthitclk=0;
9591 832 mainguy=false;
9592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9593
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9594
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9595 {
9596
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9597 399 }
9598 else
9599 {
9600
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9601 }
9602
9603
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9604 {
9605
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9606 72 }
9607
9608 //nets+((id==eTRAP_LR)?540:520);
9609 832 dummy_int[1]=0;
9610
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9611 832 }
9612
9613 346559 bool eTrap2::animate(int32_t index)
9614 {
9615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9616
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9617
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9618 11026 return enemy::animate(index);
9619
9620
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9621 {
9622 21385 removearmos(x,y,ffcactivated);
9623 21385 }
9624
9625
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9626 {
9627
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9628 {
9629 11074 --lasthitclk;
9630 11074 }
9631 else
9632 {
9633 113252 lasthit=-1;
9634 }
9635
9636 124326 bool hitenemy=false;
9637
9638
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9639 {
9640
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9641 {
9642
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9643 {
9644 3669 lasthit=j;
9645 3669 lasthitclk=10;
9646 3669 hitenemy=true;
9647 3669 guys.spr(j)->lasthit=index;
9648 3669 guys.spr(j)->lasthitclk=10;
9649 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9650 3669 }
9651 730351 }
9652 864860 }
9653
9654
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9655 {
9656
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9657 {
9658 3155 lasthit=-1;
9659 3155 lasthitclk=0;
9660 3155 }
9661
9662
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9663 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9664
9665 5986 dir=dir^1;
9666 5986 }
9667
9668 124326 sprite::move(step);
9669 124326 }
9670 else
9671 {
9672
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9673 {
9674
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9675 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9676
9677 6919 dir=dir^1;
9678 6919 }
9679
9680 211207 sprite::move(step);
9681 }
9682
9683 335533 return enemy::animate(index);
9684 346559 }
9685
9686 341519 bool eTrap2::trapmove(int32_t ndir)
9687 {
9688
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(tmpscr->flags2&fFLOATTRAPS)
9689 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9690
9691 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9692 341519 }
9693
9694 328290 bool eTrap2::clip()
9695 {
9696
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9697 {
9698 case up:
9699
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9700
9701 88320 break;
9702
9703 case down:
9704
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=160) return true;
9705
9706 89029 break;
9707
9708 case left:
9709
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9710
9711 75153 break;
9712
9713 case right:
9714
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=240) return true;
9715
9716 75788 break;
9717 }
9718
9719 328290 return false;
9720 328290 }
9721
9722 350933 void eTrap2::draw(BITMAP *dest)
9723 {
9724 350933 update_enemy_frame();
9725 350933 enemy::draw(dest);
9726 350933 }
9727
9728 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9729 {
9730 3169 return 0;
9731 }
9732
9733 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9734 354 {
9735 //do not show "enemy appering" anim -DD
9736 354 clk=0;
9737 354 mainguy=false;
9738 354 clk2=-14;
9739 //Enemy Editor Size Tab
9740
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9741 //nets+1640;
9742 354 }
9743
9744 354 void eRock::init_size_flags()
9745 {
9746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9747 354 else hxofs = -2;
9748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9749 354 else hyofs = -2;
9750
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9751 354 else hit_width = 20;
9752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9753 354 else hit_height = 20;
9754
9755
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9756
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9757
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9758
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9759
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
9760 {
9761 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9762 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9763 }
9764
9765
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9766 354 }
9767
9768 121997 bool eRock::animate(int32_t index)
9769 {
9770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9771
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9773 return Dead(index);
9774
9775
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9776 {
9777 8376 removearmos(x,y,ffcactivated);
9778 8376 }
9779
9780
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9781 {
9782 697 x=zc_oldrand()&0xF0;
9783 697 y=0;
9784 697 clk3=0;
9785 697 clk2=zc_oldrand()&15;
9786 697 }
9787
9788
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9789 {
9790
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9791 {
9792 3430 dir=zc_oldrand()&1;
9793
9794
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9795
9796
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9797 3430 }
9798
9799
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9800 {
9801 95993 x += dir ? 1 : -1; //right, left
9802 95993 dummy_int[1]=dir;
9803
9804
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9805 {
9806 6852 y-=2; //up
9807 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9808 6852 }
9809
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9810 {
9811 10208 y--; //up
9812 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9813 10208 }
9814
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9815 {
9816 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9817 10135 }
9818
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9819 {
9820 10058 y++; //down
9821 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9822 10058 }
9823 else
9824 {
9825 58740 y+=2; //down
9826 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9827 }
9828
9829 95993 ++clk3;
9830 95993 }
9831
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<176)
9832 2761 clk3=0; // next bounce
9833 else
9834 423 clk2 = -(zc_oldrand()&63); // back to top
9835 99177 }
9836
9837 121997 return enemy::animate(index);
9838 121997 }
9839
9840 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9841 {
9842
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9843 {
9844 44250 int32_t tempy=yofs;
9845 44250 flip = 0;
9846 44250 int32_t fdiv = frate/4;
9847
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9848
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9849 44250 efrate:((clk>=(frate>>1))?1:0);
9850 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9851
9852 44250 yofs+=8;
9853
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9855 44250 sprite::drawshadow(dest, translucent);
9856 44250 yofs=tempy;
9857 44250 }
9858 51441 }
9859
9860 122078 void eRock::draw(BITMAP *dest)
9861 {
9862
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9863 {
9864 105043 int32_t tempdir=dir;
9865 105043 dir=dummy_int[2];
9866 105043 update_enemy_frame();
9867 105043 enemy::draw(dest);
9868 105043 dir=tempdir;
9869 105043 }
9870 122078 }
9871
9872 1014 int32_t eRock::takehit(weapon*,weapon*)
9873 {
9874 1014 return 0;
9875 }
9876
9877 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9878 30 {
9879 30 clk=0;
9880 30 mainguy=false;
9881 30 clk2=-14;
9882
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9883 //nets+1680;
9884 30 }
9885
9886 4440 bool eBoulder::animate(int32_t index)
9887 {
9888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9889
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9891 return Dead(index);
9892
9893
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9894 {
9895 290 removearmos(x,y,ffcactivated);
9896 290 }
9897
9898 zfix *vert;
9899
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9900
9901
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9902 {
9903 32 x=zc_oldrand()&0xF0;
9904 32 y=-32;
9905 32 clk3=0;
9906 32 clk2=zc_oldrand()&15;
9907 32 }
9908
9909
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9910 {
9911
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9912 {
9913 131 dir=zc_oldrand()&1;
9914
9915
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9916
9917
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9918 131 }
9919
9920
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9921 {
9922 3487 x += dir ? 1 : -1; //right, left
9923 3487 dummy_int[1]=dir;
9924
9925
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9926 {
9927 261 y-=2; //up
9928 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9929 261 }
9930
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9931 {
9932 382 y--; //up
9933 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9934 382 }
9935
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
9936 {
9937 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
9938 376 }
9939
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
9940 {
9941 367 y++; //down
9942 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9943 367 }
9944 else
9945 {
9946 2101 y+=2; //down
9947 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9948 }
9949
9950 3487 ++clk3;
9951 3487 }
9952
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
9953 101 clk3=0; // next bounce
9954 else
9955 10 clk2 = -(zc_oldrand()&63); // back to top
9956 3598 }
9957
9958 4440 return enemy::animate(index);
9959 4440 }
9960
9961 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
9962 {
9963
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
9964 {
9965 3868 int32_t tempy=yofs;
9966 3868 flip = 0;
9967 3868 int32_t f2=((clk<<2)/frate)<<1;
9968 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9969
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9970
9971 3868 yofs+=8;
9972 3868 xofs-=8;
9973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9974 3868 sprite::drawshadow(dest, translucent);
9975 3868 xofs+=16;
9976 3868 ++shadowtile;
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9978 3868 sprite::drawshadow(dest, translucent);
9979 3868 yofs+=16;
9980 3868 shadowtile+=20;
9981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9982 3868 sprite::drawshadow(dest, translucent);
9983 3868 xofs-=16;
9984 3868 --shadowtile;
9985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9986 3868 sprite::drawshadow(dest, translucent);
9987 3868 xofs+=8;
9988 3868 yofs=tempy;
9989 3868 }
9990 4440 }
9991
9992 4440 void eBoulder::draw(BITMAP *dest)
9993 {
9994
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
9995 {
9996 3868 int32_t tempdir=dir;
9997 3868 dir=dummy_int[2];
9998 3868 update_enemy_frame();
9999 3868 dir=tempdir;
10000 3868 xofs-=8;
10001 3868 yofs-=8;
10002 3868 drawblock(dest,15);
10003 3868 xofs+=8;
10004 3868 yofs+=8;
10005 // enemy::draw(dest);
10006 3868 }
10007 4440 }
10008
10009 30 void eBoulder::init_size_flags()
10010 {
10011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10012 30 else hxofs = -10;
10013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10014 30 else hyofs = -10;
10015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10016 30 else hit_width = 36;
10017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10018 30 else hit_height = 36;
10019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10020 30 else hzsz = 16; //can't be jumped
10021
10022
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10023
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10025
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10026
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
10027 {
10028 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10029 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10030 }
10031
10032
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10033 30 }
10034
10035 int32_t eBoulder::takehit(weapon*,weapon*)
10036 {
10037 return 0;
10038 }
10039
10040 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10041
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10042 4429 {
10043 /* fixing
10044 hp=1;
10045 */
10046 4429 mainguy=false;
10047
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10048 4429 hclk=clk; // the "no fire" range
10049 4429 clk=0;
10050 4429 clk3=96;
10051 4429 timer=0;
10052
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10053 {
10054 4415 superman=1;
10055 4415 hxofs=1000;
10056 4415 }
10057
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10058 4429 }
10059
10060 2504746 bool eProjectile::animate(int32_t index)
10061 {
10062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10063
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10064
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10065 {
10066 12326 removearmos(x,y,ffcactivated);
10067 12326 }
10068
10069 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10070 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10071
10072
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10073 {
10074 403631 dir=down;
10075 403631 }
10076
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10077 {
10078 916920 dir=right;
10079 916920 }
10080
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10081 {
10082 358900 dir=up;
10083 358900 }
10084 else
10085 {
10086 825295 dir=left;
10087 }
10088
10089
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10090 {
10091
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10092 {
10093
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10094 {
10095 563 unsigned r=zc_oldrand();
10096
10097
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10098 {
10099 6 timer=zc_oldrand()%50+50;
10100 6 }
10101 563 }
10102
10103
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10104 {
10105
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10106 {
10107 119 FireBreath(false);
10108 119 }
10109
10110
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10111 {
10112 6 clk3=0;
10113 6 }
10114 489 }
10115 1046 }
10116
10117 else // Not breath type
10118 {
10119 1197433 unsigned r=zc_oldrand();
10120
10121
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10122 {
10123 17542 FireWeapon();
10124
10125
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10126
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10127 {
10128
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10129 {
10130 909 x-=4;
10131 909 FireWeapon();
10132 909 x+=4;
10133 909 }
10134 14854 }
10135
10136 17542 clk3=0;
10137 17542 }
10138 }
10139 1198479 }
10140
10141 2504746 return enemy::animate(index);
10142 2504746 }
10143
10144 2520335 void eProjectile::draw(BITMAP *dest)
10145 {
10146 2520335 update_enemy_frame();
10147 2520335 enemy::draw(dest);
10148 2520335 }
10149
10150 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10151 533 {
10152 533 hxofs=1000;
10153 533 }
10154
10155 249811 void eTrigger::draw(BITMAP *dest)
10156 {
10157 249811 update_enemy_frame();
10158 249811 enemy::draw(dest);
10159 249811 }
10160
10161 void eTrigger::death_sfx()
10162 {
10163 //silent death
10164 }
10165
10166 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10167 5 {
10168 5 o_tile+=wpnsbuf[iwNPCs].tile;
10169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10170 5 SIZEflags = d->SIZEflags;
10171
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10172 5 }
10173
10174 75 bool eNPC::animate(int32_t index)
10175 {
10176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10177
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10178 70 return Dead(index);
10179
10180
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10181 {
10182 removearmos(x,y,ffcactivated);
10183 }
10184
10185
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10186 {
10187 case 0:
10188 {
10189 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10190 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10191
10192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10193 {
10194 dir=down;
10195 }
10196
10197
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10198 {
10199 5 dir=right;
10200 5 }
10201 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10202 {
10203 dir=up;
10204 }
10205 else
10206 {
10207 dir=left;
10208 }
10209 }
10210 5 break;
10211
10212 case 1:
10213 halting_walk(rate, homing, 0, hrate, 48);
10214
10215 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10216 {
10217 newdir(rate, homing, 0);
10218 clk2=48;
10219 ++misc;
10220 }
10221
10222 if(clk2==0)
10223 misc=0;
10224
10225 break;
10226 }
10227
10228 5 return enemy::animate(index);
10229 75 }
10230
10231 75 void eNPC::draw(BITMAP *dest)
10232 {
10233 75 update_enemy_frame();
10234 75 enemy::draw(dest);
10235 75 }
10236
10237 int32_t eNPC::takehit(weapon*,weapon*)
10238 {
10239 return 0;
10240 }
10241
10242 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10243 94 {
10244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10245 {
10246 94 o_tile=clk;
10247 94 cs=id>>12;
10248 94 }
10249
10250 94 id=id&0xFFF;
10251 94 clk=0;
10252
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10253 94 mainguy=false;
10254 94 SIZEflags = d->SIZEflags;
10255
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10256 94 }
10257
10258 81 void eSpinTile::facehero()
10259 {
10260
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10261 {
10262
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10263 1 dir = up;
10264 else
10265 dir = down;
10266 1 }
10267 else
10268 {
10269 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10270 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10271
10272
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10273 {
10274 12 dir=l_down;
10275 12 }
10276
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10277 {
10278 1 dir=down;
10279 1 }
10280
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10281 {
10282 12 dir=r_down;
10283 12 }
10284
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10285 {
10286 6 dir=right;
10287 6 }
10288
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10289 {
10290 17 dir=r_up;
10291 17 }
10292
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10293 {
10294 8 dir=up;
10295 8 }
10296
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10297 {
10298 6 dir=l_up;
10299 6 }
10300 else
10301 {
10302 18 dir=left;
10303 }
10304 }
10305 81 }
10306
10307
10308 15539 bool eSpinTile::animate(int32_t index)
10309 {
10310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10311
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10312
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10313 {
10314 1152 return Dead(index);
10315 }
10316
10317
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10318 {
10319 1241 removearmos(x,y,ffcactivated);
10320 1241 }
10321
10322 14387 ++misc;
10323
10324
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10325 {
10326 81 facehero();
10327 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10328 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10329 81 angular=true;
10330 81 angle=ddir;
10331 81 step=zslongToFix(dstep*100);
10332 81 }
10333
10334
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10335 52 kickbucket();
10336
10337 14387 sprite::move(step);
10338 14387 return enemy::animate(index);
10339 15539 }
10340
10341 15457 void eSpinTile::draw(BITMAP *dest)
10342 {
10343 15457 update_enemy_frame();
10344 15457 y-=(misc>>4);
10345 15457 yofs+=2;
10346 15457 enemy::draw(dest);
10347 15457 yofs-=2;
10348 15457 y+=(misc>>4);
10349 15457 }
10350
10351 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10352 {
10353 15457 flip = 0;
10354 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10355 15457 yofs+=4;
10356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10357 15457 enemy::drawshadow(dest, translucent);
10358 15457 yofs-=4;
10359 15457 }
10360
10361 2765 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10362 2765 {
10363 //these are here to bypass compiler warnings about unused arguments
10364 2765 Clk=Clk;
10365 2765 mainguy=false;
10366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
2765 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10367 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10368 {
10369 clk=1;
10370 }*/
10371 //nets+880;
10372
1/4
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if (SIZEflags != 0) init_size_flags();;
10373 2765 }
10374
10375 623626 void eZora::facehero()
10376 {
10377
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 612841 times.
623626 if(Hero.x-x==0)
10378 {
10379 10785 dir=(Hero.y+8<y)?up:down;
10380 10785 }
10381 else
10382 {
10383 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10384 612841 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10385
10386
4/4
✓ Branch 0 taken 124342 times.
✓ Branch 1 taken 488499 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 78312 times.
612841 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10387 {
10388 78312 dir=l_down;
10389 78312 }
10390
4/4
✓ Branch 0 taken 90275 times.
✓ Branch 1 taken 444254 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 44245 times.
534529 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10391 {
10392 44245 dir=down;
10393 44245 }
10394
4/4
✓ Branch 0 taken 119526 times.
✓ Branch 1 taken 370758 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 73496 times.
490284 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10395 {
10396 73496 dir=r_down;
10397 73496 }
10398
4/4
✓ Branch 0 taken 160722 times.
✓ Branch 1 taken 256066 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 114692 times.
416788 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10399 {
10400 114692 dir=right;
10401 114692 }
10402
4/4
✓ Branch 0 taken 125815 times.
✓ Branch 1 taken 176281 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 79785 times.
302096 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10403 {
10404 79785 dir=r_up;
10405 79785 }
10406
4/4
✓ Branch 0 taken 87885 times.
✓ Branch 1 taken 134426 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 41855 times.
222311 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10407 {
10408 41855 dir=up;
10409 41855 }
10410
4/4
✓ Branch 0 taken 120580 times.
✓ Branch 1 taken 59876 times.
✓ Branch 2 taken 74550 times.
✓ Branch 3 taken 46030 times.
180456 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10411 {
10412 74550 dir=l_up;
10413 74550 }
10414 else
10415 {
10416 105906 dir=left;
10417 }
10418 }
10419 623626 }
10420
10421 852265 bool eZora::animate(int32_t index)
10422 {
10423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 852265 times.
852265 if(switch_hooked) return enemy::animate(index);
10424
2/2
✓ Branch 0 taken 2754 times.
✓ Branch 1 taken 849511 times.
852265 if(dying)
10425 2754 return Dead(index);
10426
10427
2/2
✓ Branch 0 taken 843799 times.
✓ Branch 1 taken 5712 times.
849511 if(clk==0)
10428 {
10429 5712 removearmos(x,y,ffcactivated);
10430 5712 }
10431
10432
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 849476 times.
849511 if(watch)
10433 {
10434 35 ++clock_zoras[id];
10435 35 return true;
10436 }
10437
10438
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 623626 times.
849476 if(get_qr(qr_NEWENEMYTILES))
10439 {
10440 623626 facehero();
10441 623626 }
10442
10443
6/6
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 4963 times.
✓ Branch 2 taken 4164 times.
✓ Branch 3 taken 825736 times.
✓ Branch 4 taken 6448 times.
✓ Branch 5 taken 2965 times.
849476 switch(clk)
10444 {
10445 case 0: // reposition him
10446 {
10447 6448 int32_t t=0;
10448 6448 int32_t pos2=zc_oldrand()%160 + 16;
10449 6448 bool placed=false;
10450
10451
4/4
✓ Branch 0 taken 6383 times.
✓ Branch 1 taken 38203 times.
✓ Branch 2 taken 26108 times.
✓ Branch 3 taken 5712 times.
44586 while(!placed && t<160)
10452 {
10453 26108 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10454
5/6
✓ Branch 0 taken 6570 times.
✓ Branch 1 taken 19538 times.
✓ Branch 2 taken 6570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5647 times.
32155 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10455
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6538 times.
6570 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10456
3/4
✓ Branch 0 taken 6538 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6047 times.
✓ Branch 3 taken 6015 times.
6570 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10457 {
10458 5647 x=(pos2&15)<<4;
10459 5647 y=pos2&0xF0;
10460
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5307 times.
5647 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10461 5647 hxofs=1000; // avoid hit detection
10462 5647 stunclk=0;
10463 5647 placed=true;
10464 5647 }
10465
10466 38138 pos2+=19;
10467
10468
2/2
✓ Branch 0 taken 33615 times.
✓ Branch 1 taken 4523 times.
38138 if(pos2>=176)
10469 4523 pos2-=160;
10470
10471 38138 ++t;
10472 }
10473
10474
3/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5647 times.
5712 if(!placed || whistleclk>=88) // can't place him, he's gone
10475 65 return true;
10476
10477 }
10478 5647 break;
10479
10480 case 35:
10481
2/2
✓ Branch 0 taken 3839 times.
✓ Branch 1 taken 1361 times.
5200 if(!get_qr(qr_NEWENEMYTILES))
10482 {
10483 1361 dir=(Hero.y+8<y)?up:down;
10484 1361 }
10485
10486 5200 hxofs=0;
10487 5200 break;
10488
10489 case 35+19:
10490 4963 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10491 4963 sfx(wpnsfx(wpn),pan(int32_t(x)));
10492 4963 break;
10493
10494 case 35+66:
10495 4164 hxofs=1000;
10496 4164 break;
10497
10498 case 198:
10499 2965 clk=-1;
10500 2965 break;
10501 }
10502
10503 848675 return enemy::animate(index);
10504 851529 }
10505
10506 857650 void eZora::draw(BITMAP *dest)
10507 {
10508
2/2
✓ Branch 0 taken 16963 times.
✓ Branch 1 taken 840687 times.
857650 if(clk<3)
10509 16963 return;
10510
10511 840687 update_enemy_frame();
10512 840687 enemy::draw(dest);
10513 857650 }
10514
10515 232 bool eZora::isSubmerged() const
10516 {
10517 232 return ( clk < 3 );
10518 }
10519
10520
3/6
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50116 times.
✗ Branch 5 not taken.
100232 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10521 50116 {
10522 50116 multishot= timer = fired = dashing = 0;
10523 50116 hashero = false;
10524 50116 dummy_bool[0]=false;
10525
4/8
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50116 times.
✗ Branch 7 not taken.
50116 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10526
5/6
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 49154 times.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 467 times.
50116 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10527 {
10528
2/4
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 495 times.
✗ Branch 3 not taken.
495 step=zslongToFix(dmisc10*100);
10529
10530
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 477 times.
495 if(anim==aARMOS4) o_tile+=20;
10531 495 }
10532
10533
3/4
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 49154 times.
50116 if(flags & guy_fade_flicker)
10534 {
10535 962 clk=0;
10536 962 superman = 1;
10537 962 fading=fade_flicker;
10538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10539 962 dir=down;
10540
10541
4/6
✓ Branch 0 taken 962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✓ Branch 5 taken 553 times.
962 if(!canmove(down,(zfix)8,spw_none,false))
10542
3/6
✓ Branch 0 taken 409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
409 clk3=int32_t(13.0/step);
10543 962 }
10544
3/4
✓ Branch 0 taken 49154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49021 times.
✓ Branch 3 taken 133 times.
49154 else if(flags & guy_fade_instant)
10545 {
10546 133 clk=0;
10547 133 }
10548
10549
1/2
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
50116 shadowdistance = 0;
10550 50116 clk4 = clk5 = 0;
10551 //nets+2380;
10552
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50114 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50116 if (SIZEflags != 0) init_size_flags();;
10553 50116 }
10554
10555 15799295 bool eStalfos::animate(int32_t index)
10556 {
10557
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15799039 times.
15799295 if(switch_hooked) return enemy::animate(index);
10558
3/4
✓ Branch 0 taken 15798613 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15798613 times.
15799039 if(fallclk||drownclk)
10559 {
10560 426 return enemy::animate(index);
10561 }
10562
2/2
✓ Branch 0 taken 352690 times.
✓ Branch 1 taken 15445923 times.
15798613 if(dying)
10563 {
10564
2/2
✓ Branch 0 taken 352642 times.
✓ Branch 1 taken 48 times.
352690 if(hashero)
10565 {
10566 48 Hero.setEaten(0);
10567 48 hashero=false;
10568 48 }
10569
10570
10/14
✓ Branch 0 taken 35920 times.
✓ Branch 1 taken 316770 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32235 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352690 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10571 {
10572 187 hp=-1000;
10573
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10574 187 Ewpns.add(ew);
10575 187 ew->fakez = fakez;
10576
10577
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10578 {
10579 187 ew->step=0;
10580 187 ew->id=wpn;
10581 187 ew->misc=50;
10582 187 ew->clk=48;
10583 187 }
10584
10585 187 fired=true;
10586 187 }
10587
6/6
✓ Branch 0 taken 156270 times.
✓ Branch 1 taken 196233 times.
✓ Branch 2 taken 130218 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130200 times.
✓ Branch 5 taken 18 times.
352503 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10588 {
10589
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10590 {
10591 1 int32_t wpn2 = wpn+dmisc3;
10592
10593
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10594 {
10595 wpn2=wpn;
10596 }
10597
10598 1 dummy_bool[0]=true;
10599 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10600 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10601 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10602 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10603 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10604 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10605 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10606 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10607 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10608 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10609 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10610 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10611 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10612 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10613 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10614 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10615 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10616 1 }
10617 18 }
10618
10619 352690 KillWeapon();
10620 352690 return Dead(index);
10621 }
10622 //vire split
10623 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10624 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10625
13/14
✓ Branch 0 taken 21125 times.
✓ Branch 1 taken 15424798 times.
✓ Branch 2 taken 21125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20774 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14252876 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15445923 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10626 {
10627 1677 stop_bgsfx(index);
10628 1677 int32_t kids = guys.Count();
10629 1677 int32_t id2=dmisc3;
10630
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10631 {
10632 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10633
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10634 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10635 3307 }
10636
10637
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 1 times.
1677 if(itemguy) // Hand down the carried item
10638 {
10639 1 guycarryingitem = guys.Count()-1;
10640 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10641 1 itemguy = false;
10642 1 }
10643
10644
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10645 {
10646 17 Hero.setEaten(0);
10647 17 hashero=false;
10648 17 }
10649
10650
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10651 323 sfx(deadsfx,pan(int32_t(x)));
10652
10653 1677 return true;
10654 }
10655 /*
10656 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10657 {
10658 stop_bgsfx(index);
10659 int32_t kids = guys.Count();
10660 int32_t id2=dmisc3;
10661
10662 for(int32_t i=0; i < dmisc4; i++)
10663 {
10664 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10665 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
10666 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10667 }
10668
10669 if(itemguy) // Hand down the carried item
10670 {
10671 guycarryingitem = guys.Count()-1;
10672 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10673 itemguy = false;
10674 }
10675
10676 if(hashero)
10677 {
10678 Hero.setEaten(0);
10679 hashero=false;
10680 }
10681
10682 return true;
10683 }
10684 */
10685
2/2
✓ Branch 0 taken 68935 times.
✓ Branch 1 taken 15375311 times.
15444246 if(fading)
10686 {
10687
2/2
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 67744 times.
68935 if(++clk4 > 60)
10688 {
10689 1191 clk4=0;
10690 1191 superman=0;
10691 1191 fading=0;
10692
10693
4/6
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 930 times.
1191 if(flags&guy_armos && z==0 && fakez == 0)
10694 {
10695 //if a custom size (not 16px by 16px)
10696
10697 //if a custom size (not 16px by 16px)
10698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
930 if (ffcactivated)
10699 removearmosffc(ffcactivated-1);
10700 else
10701 {
10702
4/8
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 930 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 930 times.
930 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10703 {
10704 //zprint("spawn big enemy from armos\n");
10705 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10706 for(int32_t dx = 0; dx < tysz; dx ++)
10707 {
10708 for(int32_t dy = 0; dy < tysz; dy++)
10709 {
10710 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10711 did_armos = false;
10712 }
10713 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10714 did_armos = false;
10715 }
10716 for(int32_t dy = 0; dy < tysz; dy ++)
10717 {
10718 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10719 did_armos = false;
10720 }
10721 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10722 }
10723 930 else removearmos(x,y);
10724 }
10725 /*
10726 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10727 {
10728 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10729 for(int32_t dx = 0; dx < hxsz; dx += 16)
10730 {
10731 for(int32_t dy = 0; dy < hysz; dy += 16)
10732 {
10733 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
10734 did_armos = false;
10735 }
10736 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10737 did_armos = false;
10738 }
10739 for(int32_t dy = 0; dy < hysz; dy += 16)
10740 {
10741 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
10742 did_armos = false;
10743 }
10744 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10745 }
10746 else removearmos(x,y,ffcactivated);
10747 */
10748
10749 930 }
10750
10751 1191 clk2=0;
10752
10753 1191 newdir();
10754 1191 }
10755 67744 else return enemy::animate(index);
10756 1191 }
10757
6/8
✓ Branch 0 taken 144960 times.
✓ Branch 1 taken 15230351 times.
✓ Branch 2 taken 144960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 144960 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135643 times.
✓ Branch 7 taken 9317 times.
15375311 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10758 9317 removearmos(x,y,ffcactivated);
10759
10760
10761
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15369295 times.
15376502 if(hashero)
10762 {
10763 7207 Hero.setX(x);
10764 7207 Hero.setY(y);
10765 7207 ++clk2;
10766
10767
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10768 {
10769
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10770 {
10771 case e7tEATITEMS:
10772 {
10773
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10774 {
10775
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10776 22 game->set_item(i, false);
10777 5632 }
10778
10779 22 break;
10780 }
10781
10782 case e7tEATMAGIC:
10783 game->change_dmagic(-1*game->get_magicdrainrate());
10784 break;
10785
10786 case e7tEATRUPEES:
10787 game->change_drupy(-1);
10788 break;
10789 }
10790
10791 899 clk2=0;
10792 899 }
10793
10794
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10795 6661 --clk;
10796 7207 }
10797
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14320422 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15369295 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10798 {
10799 // Movement engine
10800
6/6
✓ Branch 0 taken 838865 times.
✓ Branch 1 taken 14097594 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14094133 times.
✓ Branch 5 taken 59 times.
14936459 if(clk>=0) switch(id>>12)
10801 {
10802 case 0: // Normal movement
10803
10804 /*
10805 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10806 {
10807 // Overloading clk4 (Tribble clock) here...
10808 step=17/100.0;
10809 if(clk4<32) misc=1;
10810 else if(clk4<48) misc=2;
10811 else if(clk4<300) { misc=3; step = dstep/100.0; }
10812 else if(clk4<316) misc=2;
10813 else if(clk4<412) misc=1;
10814 else if(clk4<540) { misc=0; step=0; }
10815 else clk4=0;
10816 if(clk4==48) clk=0;
10817 hxofs=(misc>=2)?0:1000;
10818 if (dmisc9==e9tLEEVER)
10819 variable_walk(rate, homing, 0);
10820 else
10821 variable_walk_8(rate, homing, 4, 0);
10822 break;
10823 }
10824 */
10825
4/4
✓ Branch 0 taken 13715099 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13298023 times.
14094133 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10826 {
10827 796110 vire_hop();
10828 796110 break;
10829 }
10830
2/2
✓ Branch 0 taken 981551 times.
✓ Branch 1 taken 12316472 times.
13298023 else if(dmisc9==e9tROPE) //Rope charge
10831 {
10832
9/10
✓ Branch 0 taken 964129 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138340 times.
✓ Branch 3 taken 825789 times.
✓ Branch 4 taken 126255 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125430 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125430 times.
981551 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10833 {
10834
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116354 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125430 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10835 {
10836
10837
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10838 {
10839 14 hp=-1000;
10840
10841
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10842 {
10843
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10844 14 Ewpns.add(ew);
10845 14 ew->fakez = fakez;
10846
10847
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10848 {
10849 14 ew->step=0;
10850 14 ew->id=wpn+dmisc3;
10851 14 ew->misc=50;
10852 14 ew->clk=48;
10853 14 }
10854
10855 14 fired=true;
10856 14 }
10857 else
10858 {
10859 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10860 Ewpns.add(ew);
10861 ew->fakez = fakez;
10862
10863 if(wpn==ewSBomb || wpn==ewBomb)
10864 {
10865 ew->step=0;
10866 ew->id=wpn;
10867 ew->misc=50;
10868 ew->clk=48;
10869 }
10870
10871 fired=true;
10872 }
10873 14 }
10874
10875 else
10876 {
10877 33 hp=-1000;
10878
10879 int32_t wpn2;
10880
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10881 33 wpn2=wpn;
10882 else
10883 wpn2=wpn;
10884
10885
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10886 33 Ewpns.add(ew);
10887 33 ew->fakez = fakez;
10888
10889
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10890 {
10891 33 ew->step=0;
10892 33 ew->id=wpn2;
10893 33 ew->misc=50;
10894 33 ew->clk=48;
10895 33 }
10896
10897 33 fired=true;
10898 }
10899 47 }
10900 125430 }
10901
10902 981551 charge_attack();
10903 981551 break;
10904 }
10905 /*
10906 * Boomerang-throwers have a halt count of 1
10907 * Zols have a halt count of (zc_oldrand()&7)<<4
10908 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10909 * Everything else has 48
10910 */
10911 else
10912 {
10913
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11748053 times.
12316472 if(wpn==ewBrang) // Goriya
10914 {
10915 568419 halting_walk(rate,homing,0,hrate, 1);
10916 568419 }
10917
4/4
✓ Branch 0 taken 11602163 times.
✓ Branch 1 taken 145890 times.
✓ Branch 2 taken 4547555 times.
✓ Branch 3 taken 7054608 times.
11748053 else if(dmisc9==e9tNORMAL && wpn==0)
10918 {
10919
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6336635 times.
7054608 if(dmisc2==e2tSPLITHIT) // Zol
10920 {
10921 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10922 717973 }
10923
4/4
✓ Branch 0 taken 1753011 times.
✓ Branch 1 taken 4583624 times.
✓ Branch 2 taken 1537120 times.
✓ Branch 3 taken 215891 times.
6336635 else if(frate<=8 && starting_hp==1) // Gel
10924 {
10925 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10926 215891 }
10927 else // Other
10928 {
10929 6120744 halting_walk(rate,homing,0,hrate, 48);
10930 }
10931 7054608 }
10932 else // Other
10933 {
10934 4693445 halting_walk(rate,homing,0,hrate, 48);
10935 }
10936 }
10937
10938 //if not in midair, and Hero's swinging sword is nearby, jump.
10939 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10940 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10941 {
10942 facehero(false);
10943 sclk=16+((dir^1)<<8);
10944 fall=-FEATHERJUMP;
10945 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10946 }*/
10947 12316472 break;
10948
10949 // Following cases are for just after creation-by-splitting.
10950 case 1:
10951
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10952 {
10953 821 dir=up;
10954 821 step=8;
10955 821 }
10956
10957
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10958 {
10959 2504 move(step);
10960
10961
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
10962 512 dir=down;
10963 2504 }
10964
10965
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
10966 {
10967
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
10968 503 x+=16;
10969 790 }
10970
10971 3294 ++misc;
10972 3294 break;
10973
10974 case 2:
10975
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10976 {
10977 15 dir=down;
10978 15 step=8;
10979 15 }
10980
10981
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10982 {
10983 45 move(step);
10984 /*
10985 if(!canmove(dir,(zfix)0,0,false))
10986 dir=up;
10987 */
10988 45 }
10989
10990
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
10991 {
10992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
10993 14 x-=16;
10994 14 }
10995
10996 59 ++misc;
10997 59 break;
10998
10999 default:
11000
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11001 {
11002 28 dir=(zc_oldrand()%4);
11003 28 step=8;
11004 28 }
11005
11006
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11007 {
11008 83 move(step);
11009
11010
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11011 2 dir=dir^1;
11012 83 }
11013
11014
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11015 {
11016
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11017 8 x+=(dir==left ? -16 : 16);
11018 25 }
11019
11020 108 ++misc;
11021 108 break;
11022 14097594 }
11023
11024
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14911187 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14936459 if(id>>12 && misc>=4) //recently spawned by a split enemy
11025 {
11026 829 id&=0xFFF;
11027 829 step = zslongToFix(dstep*100);
11028
11029
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11030
11031
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11032
11033
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11034
11035
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11036
11037 829 misc=3;
11038 829 }
11039 14936459 }
11040 else
11041 {
11042 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11043
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11044 }
11045
11046 // Fire Zol
11047
8/8
✓ Branch 0 taken 6100125 times.
✓ Branch 1 taken 9276377 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5960844 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15376502 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11048 {
11049 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11050 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11051
11052 1102 int32_t i=Ewpns.Count()-1;
11053 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11054
11055
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11056 {
11057 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11058 if ( ew->do_animation ) ew->tile+=ew->aframe;
11059 }
11060 1102 }
11061 // Goriya
11062
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14326527 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15375400 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11063 {
11064 6362 misc=index+100;
11065
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11066 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11067
11068
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11069 {
11070 257 int32_t ndir=dir;
11071
11072
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11073 {
11074 6 ndir=(Hero.y+8<y)?up:down;
11075 6 }
11076 else //turn to face Hero
11077 {
11078 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11079 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11080
11081
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11082 {
11083 13 ndir=down;
11084 13 }
11085
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11086 {
11087 68 ndir=right;
11088 68 }
11089
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11090 {
11091 48 ndir=up;
11092 48 }
11093 else
11094 {
11095 122 ndir=left;
11096 }
11097 }
11098
11099 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11100
11101
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11102 {
11103 223 dir=ndir;
11104 223 }
11105 257 }
11106 6362 }
11107
15/16
✓ Branch 0 taken 15310158 times.
✓ Branch 1 taken 58880 times.
✓ Branch 2 taken 221196 times.
✓ Branch 3 taken 15147842 times.
✓ Branch 4 taken 195078 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170186 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168774 times.
✓ Branch 9 taken 1412 times.
✓ Branch 10 taken 153626 times.
✓ Branch 11 taken 15148 times.
✓ Branch 12 taken 153626 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152682 times.
15369038 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11108
3/3
✓ Branch 0 taken 26116 times.
✓ Branch 1 taken 125660 times.
✓ Branch 2 taken 906 times.
152682 switch(dmisc1)
11109 {
11110 case e1tCONSTANT: //Deathnut
11111 {
11112 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11113
2/2
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 2581 times.
125660 if(clk5>64)
11114 {
11115 2581 clk5=0;
11116 2581 fired=false;
11117 2581 }
11118
11119 125660 clk5+=(zc_oldrand()&3);
11120
11121
4/4
✓ Branch 0 taken 76669 times.
✓ Branch 1 taken 48991 times.
✓ Branch 2 taken 25622 times.
✓ Branch 3 taken 51047 times.
125660 if((clk5>24)&&(clk5<52))
11122 {
11123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51047 times.
51047 if ( do_animation )tile+=20; //firing
11124
11125
4/4
✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 23097 times.
✓ Branch 2 taken 25124 times.
✓ Branch 3 taken 2826 times.
51047 if(!fired&&(clk5>=38))
11126 {
11127
5/10
✓ Branch 0 taken 2826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2826 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2826 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2826 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2826 times.
✗ Branch 9 not taken.
2826 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11128 2826 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11129 2826 sfx(wpnsfx(wpn),pan(int32_t(x)));
11130 2826 fired=true;
11131 2826 }
11132 51047 }
11133
11134 125660 break;
11135 }
11136
11137 case e1tFIREOCTO: //Fire Octo
11138 906 timer=zc_oldrand()%50+50;
11139 906 break;
11140
11141 default:
11142 26116 FireWeapon();
11143 26116 break;
11144 152682 }
11145
11146 /* Fire again if:
11147 * - clk2 about to run out
11148 * - not already double-firing (dmisc1 is 1)
11149 * - not carrying Hero
11150 * - one in 0xF chance
11151 */
11152
8/10
✓ Branch 0 taken 524932 times.
✓ Branch 1 taken 14851570 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520930 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15376502 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11153 {
11154 #if 1
11155 251 newdir(rate, homing, grumble);
11156 #else
11157 dir^=2;
11158 #endif
11159 251 clk2=28;
11160 251 ++multishot;
11161 251 }
11162
11163
2/2
✓ Branch 0 taken 3492313 times.
✓ Branch 1 taken 11884189 times.
15376502 if(clk2==0)
11164 {
11165 11884189 multishot = 0;
11166 11884189 }
11167
11168
2/2
✓ Branch 0 taken 15312192 times.
✓ Branch 1 taken 64310 times.
15376502 if(timer) //Fire Octo
11169 {
11170 64310 clk2=15; //this keeps the octo in place until he's done firing
11171
11172
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11173 {
11174 15752 FireBreath(false);
11175 15752 }
11176
11177 64310 --timer;
11178 64310 }
11179
11180
2/2
✓ Branch 0 taken 15127109 times.
✓ Branch 1 taken 249393 times.
15376502 if(dmisc2==e2tTRIBBLE)
11181 249393 ++clk4;
11182
11183
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15372022 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15375809 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15376502 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11184 {
11185 693 int32_t kids = guys.Count();
11186 693 int32_t id2=dmisc3;
11187
11188
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11189 {
11190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(x,y,id2,-24))
11191 {
11192
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11193 {
11194 guycarryingitem = guys.Count()-1;
11195 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11196 itemguy = false;
11197 }
11198
11199 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11200 693 }
11201 693 }
11202
11203
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11204 {
11205 Hero.setEaten(0);
11206 hashero=false;
11207 }
11208
11209 693 stop_bgsfx(index);
11210 693 return true;
11211 }
11212
11213 15375809 return enemy::animate(index);
11214 15799295 }
11215
11216 16194890 void eStalfos::draw(BITMAP *dest)
11217 {
11218 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11219 {
11220 clk4--; //Kludge
11221 return;
11222 }*/
11223
11224 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11225 {
11226 cs = dcset;
11227 }*/
11228 16194890 update_enemy_frame();
11229
11230
7/8
✓ Branch 0 taken 16194464 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16194464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16107513 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16194890 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11231 {
11232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11233 11115 }
11234
11235 16194890 enemy::draw(dest);
11236 16194890 }
11237
11238 7494226 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11239 {
11240 7494226 int32_t tempy=yofs;
11241
11242 /*
11243 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11244 flip = 0;
11245 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11246 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11247 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11248 yofs+=(((int32_t)y+17)&0xF0)-y;
11249 yofs+=8;
11250 }
11251 */
11252
4/4
✓ Branch 0 taken 7278808 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7182607 times.
✓ Branch 3 taken 311619 times.
7494226 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11253 {
11254 311619 flip = 0;
11255 311619 int32_t fdiv = frate/4;
11256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11257
11258
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11259 311619 efrate:((clk>=(frate>>1))?1:0);
11260 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11261
11262
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11263 {
11264 311619 shadowtile+=f2;
11265 311619 }
11266 else
11267 {
11268 shadowtile+=f2?1:0;
11269 }
11270
11271 311619 yofs+=shadowdistance;
11272 311619 yofs+=8;
11273 311619 }
11274
4/4
✓ Branch 0 taken 7278808 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7491191 times.
✓ Branch 3 taken 3035 times.
7494226 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11275 {
11276 3035 flip = 0;
11277 3035 int32_t fdiv = frate/4;
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11279
11280
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11281 3035 efrate:((clk>=(frate>>1))?1:0);
11282 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11283
11284
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11285 {
11286 3035 shadowtile+=f2;
11287 3035 }
11288 else
11289 {
11290 shadowtile+=f2?1:0;
11291 }
11292 3035 }
11293
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7488730 times.
7494226 if(!shadow_overpit(this))
11294 7488730 enemy::drawshadow(dest, translucent);
11295 7494226 yofs=tempy;
11296 7494226 }
11297
11298 157627 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11299 {
11300 157627 int32_t wpnId = w->id;
11301 157627 int32_t wpnDir = w->dir;
11302
11303
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156209 times.
✓ Branch 2 taken 546 times.
✓ Branch 3 taken 872 times.
157627 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11304
5/8
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 185 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 185 times.
546 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11305
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
185 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11306 {
11307 361 shield = false;
11308 361 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11309
11310
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 256 times.
361 if(get_qr(qr_BRKNSHLDTILES))
11311 256 o_tile=s_tile;
11312 361 }
11313
11314 157627 int32_t ret = enemy::takehit(w,realweap);
11315
11316
4/4
✓ Branch 0 taken 22313 times.
✓ Branch 1 taken 135314 times.
✓ Branch 2 taken 20562 times.
✓ Branch 3 taken 1751 times.
157627 if(sclk && dmisc2==e2tSPLITHIT)
11317 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11318
11319 157627 return ret;
11320 }
11321
11322 981551 void eStalfos::charge_attack()
11323 {
11324
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 974836 times.
981551 if(slide())
11325 6715 return;
11326
11327
10/12
✓ Branch 0 taken 974836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 972432 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 942919 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 921366 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 915743 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915743 times.
974836 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11328 59093 return;
11329
11330
2/2
✓ Branch 0 taken 37390 times.
✓ Branch 1 taken 878353 times.
915743 if(clk3<=0)
11331 {
11332 37390 fix_coords(true);
11333
11334
2/2
✓ Branch 0 taken 10009 times.
✓ Branch 1 taken 27381 times.
37390 if(!dashing)
11335 {
11336 27381 int32_t ldir = lined_up(7,false);
11337
11338
4/4
✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 24294 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 2635 times.
27381 if(ldir!=-1 && canmove(ldir,false))
11339 {
11340 2635 dir=ldir;
11341 2635 dashing=true;
11342
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2635 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2635 if(dmisc10<=0 || replay_version_check(0,33))
11343 2635 step=zslongToFix(dstep*100)+1;
11344 else
11345 step=zslongToFix(dmisc10*100);
11346 2635 }
11347 24746 else newdir(4,0,0);
11348 27381 }
11349
11350
2/2
✓ Branch 0 taken 35948 times.
✓ Branch 1 taken 1442 times.
37390 if(!canmove(dir,false))
11351 {
11352 1442 step=zslongToFix(dstep*100);
11353 1442 newdir();
11354 1442 dashing=false;
11355 1442 }
11356
11357 37390 zfix div = step;
11358
11359
1/2
✓ Branch 0 taken 37390 times.
✗ Branch 1 not taken.
37390 if(div == 0)
11360 div = 1;
11361
11362 37390 clk3=(int32_t)(16.0/div);
11363 37390 return;
11364 }
11365
11366 878353 move(step);
11367 878353 --clk3;
11368 981551 }
11369
11370 796110 void eStalfos::vire_hop()
11371 {
11372 //if ( sclk > 0 ) return; //Don't hop during knockback.
11373
11374 // if(dmisc9!=e9tPOLSVOICE)
11375 // {
11376 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11377 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11378 // return; //the enemy should split if it is sliding!
11379 // //else sclk=0; //might need this here, too. -Z
11380 // }
11381
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11382 {
11383
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11384 {
11385
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11386 //return;
11387 3843 }
11388 376292 }
11389 417076 else sclk=0;
11390
11391
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11392 31892 return;
11393
11394 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11395 761476 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11396
11397 761476 y=floor_y;
11398
11399
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11400 {
11401 26258 fix_coords();
11402
11403 //z=0;
11404 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11405 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11406
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11407 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11408
11409
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11410 {
11411 //z=0;
11412
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11413 {
11414
11415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11416 /*if (dmisc9==e9tPOLSVOICE )
11417 {
11418 zprint2("polsvoice jump_width is: %d\n", jump_width);
11419 zprint2("polsvoice raw step is: %d\n", step);
11420 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11421 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11422 }
11423 else
11424 {
11425 zprint2("vire jump_width is: %d\n", jump_width);
11426 zprint2("vire raw step is: %d\n", step);
11427 zprint2("vire step.getInt() is: %d\n", step.getInt());
11428 zprint2("setting clk2 on vire to: %d\n", clk2);
11429 }
11430 */
11431 17258 }
11432 21336 }
11433
11434
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11435 {
11436 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11437 7030 }
11438
11439 26258 clk3=int32_t(16.0/step.getFloat());
11440 26258 }
11441
11442 761476 --clk3;
11443
11444
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11445 761476 move(step);
11446
11447 761476 floor_y=y;
11448 761476 clk2--;
11449
11450 //if we're in the middle of a jump
11451
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11452 {
11453 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11454
11455
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11456 {
11457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11458 93147 else z=h;
11459 93147 }
11460 else
11461 {
11462 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11463 //y-=h;
11464 384731 y=floor_y-h;
11465 384731 shadowdistance=h;
11466 }
11467 477878 }
11468 else
11469 283598 shadowdistance = 0;
11470 796110 }
11471
11472 138 void eStalfos::eathero()
11473 {
11474
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11475 {
11476 70 hashero=true;
11477 70 y=floor_y;
11478 70 z=0;
11479
11480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11481 {
11482 Hero.setX(x);
11483 Hero.setY(y);
11484 }
11485 else
11486 {
11487 70 x=Hero.getX();
11488 70 y=Hero.getY();
11489 }
11490
11491 70 clk2=0;
11492 70 }
11493 138 }
11494
11495 1469390 bool eStalfos::WeaponOut()
11496 {
11497
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11498 {
11499
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11500 {
11501 846991 return true;
11502 }
11503
11504 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11505 stop_sfx(bgsfx);
11506 */
11507 1553588 }
11508
11509 622399 return false;
11510 1469390 }
11511
11512 352690 void eStalfos::KillWeapon()
11513 {
11514
2/2
✓ Branch 0 taken 352690 times.
✓ Branch 1 taken 293384 times.
646074 for(int32_t i=0; i<Ewpns.Count(); i++)
11515 {
11516
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11517 {
11518 //only kill this Goriya's boomerang -DD
11519
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11520 {
11521 411 Ewpns.del(i);
11522 411 }
11523 810 }
11524 293384 }
11525
11526
4/4
✓ Branch 0 taken 26052 times.
✓ Branch 1 taken 326638 times.
✓ Branch 2 taken 14170 times.
✓ Branch 3 taken 11882 times.
352690 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11527 {
11528 14170 stop_sfx(WAV_BRANG);
11529 14170 }
11530 352690 }
11531
11532 void eStalfos::break_shield()
11533 {
11534 if(!shield)
11535 return;
11536
11537 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11538 shield=false;
11539
11540 if(get_qr(qr_BRKNSHLDTILES))
11541 o_tile=s_tile;
11542 }
11543
11544 13582 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11545 13582 {
11546
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 dir=(zc_oldrand()&7)+8;
11547
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 step=0;
11548 13582 movestatus=1;
11549
3/4
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10458 times.
13582 if (dmisc1 != 1 && dmisc19 > 0)
11550 {
11551 step = dmisc19/100.0;
11552 movestatus = 1;
11553 }
11554
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if (dmisc1 == 2) movestatus=2;
11555 13582 c=0;
11556 13582 clk4=0;
11557 //nets;
11558
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 init_size_flags();
11559 13582 dummy_int[1]=0;
11560 13582 }
11561
11562 3505411 bool eKeese::animate(int32_t index)
11563 {
11564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3505411 times.
3505411 if(switch_hooked) return enemy::animate(index);
11565
2/4
✓ Branch 0 taken 3505411 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3505411 times.
3505411 if(fallclk||drownclk) return enemy::animate(index);
11566
2/2
✓ Branch 0 taken 124201 times.
✓ Branch 1 taken 3381210 times.
3505411 if(dying)
11567 124201 return Dead(index);
11568
11569
2/2
✓ Branch 0 taken 3355205 times.
✓ Branch 1 taken 26005 times.
3381210 if(clk==0)
11570 {
11571 26005 removearmos(x,y,ffcactivated);
11572 26005 }
11573
11574
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2356168 times.
3381210 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11575 {
11576 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11577 1025042 }
11578 else
11579 {
11580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356168 times.
2356168 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11581 2356168 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11582 }
11583
11584
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3260872 times.
3381210 if(dmisc2 == e2tKEESETRIB)
11585 {
11586
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11587 {
11588
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11589 {
11590 105 int32_t kids = guys.Count();
11591 105 bool success = false;
11592 105 int32_t id2=dmisc3;
11593 105 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11594
11595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11596 {
11597
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11598 {
11599 guycarryingitem = guys.Count()-1;
11600 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11601 itemguy = false;
11602 }
11603
11604 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11605 105 }
11606
11607 105 stop_bgsfx(index);
11608 105 return true;
11609 }
11610 else
11611 {
11612 86 clk4=0;
11613 }
11614 86 }
11615 120233 }
11616 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11617
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2414993 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3260872 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11618 {
11619
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11620 {
11621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11622 {
11623 fakez=int32_t(step/zslongToFix(dstep*100));
11624 // Some variance in keese flight heights when away from Hero
11625 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11626
11627 }
11628 else
11629 {
11630 687068 z=int32_t(step/zslongToFix(dstep*100));
11631 // Some variance in keese flight heights when away from Hero
11632
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11633 }
11634 687068 }
11635 else
11636 {
11637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11638 {
11639 fakez=int32_t(step/zslongToFix(dstep*100));
11640 // Some variance in keese flight heights when away from Hero
11641 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11642
11643 }
11644 else
11645 {
11646 158811 z=int32_t(step/zslongToFix(dstep*100));
11647 // Some variance in keese flight heights when away from Hero
11648
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11649 }
11650 }
11651 845879 }
11652
11653 3381105 return enemy::animate(index);
11654 3505411 }
11655
11656 2056065 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11657 {
11658 2056065 int32_t tempy=yofs;
11659 2056065 flip = 0;
11660 2056065 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11661
11662
2/2
✓ Branch 0 taken 653085 times.
✓ Branch 1 taken 1402980 times.
2056065 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11663
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1365502 times.
2056065 if(!get_qr(qr_ENEMIESZAXIS))
11664 {
11665 1365502 yofs+=int32_t(step/zslongToFix(dstep*10));
11666 1365502 }
11667
11668
6/6
✓ Branch 0 taken 2035375 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1358555 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2056065 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11669 2020007 enemy::drawshadow(dest, translucent);
11670 2056065 yofs=tempy;
11671 2056065 }
11672
11673 7885431 void eKeese::draw(BITMAP *dest)
11674 {
11675 7885431 update_enemy_frame();
11676 7885431 enemy::draw(dest);
11677 7885431 }
11678
11679 13582 void eKeese::init_size_flags()
11680 {
11681 13582 SIZEflags = d->SIZEflags;
11682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11683
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11684
11685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_WIDTH)) hit_width = 12;
11686
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11687
11688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11689
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11690
11691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_HEIGHT)) hit_height = 8;
11692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11693
11694
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11695 // al_trace("Enemy txsz:%i\n", txsz);
11696
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11697
11698
11699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11700
11701
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11702
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
11703 {
11704 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11705 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11706 }
11707
11708
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11709 13582 }
11710
11711 20081 void eWizzrobe::submerge(bool set)
11712 {
11713
2/2
✓ Branch 0 taken 19934 times.
✓ Branch 1 taken 147 times.
20081 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11714 {
11715 19934 hxofs = set?1000:0;
11716 19934 return;
11717 }
11718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11719 147 submerged = set;
11720
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11721 76 hxofs+=1000;
11722 71 else hxofs -= 1000;
11723 20081 }
11724 5326 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11725 5326 {
11726 5326 hxofs = 0;
11727 5326 submerged = false;
11728
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 switch(dmisc1)
11729 {
11730 case 0:
11731 2968 submerge(true);
11732 2968 fading=fade_invisible;
11733 // Set clk to just before the 'reappear' threshold
11734
9/10
✓ Branch 0 taken 2967 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2967 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1784 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1783 times.
✓ Branch 9 taken 1 times.
2968 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11735 2968 break;
11736
11737 default:
11738 2358 dir=(loadside==right)?right:left;
11739 2358 misc=-3;
11740 2358 break;
11741 }
11742
11743 //netst+2880;
11744 5326 charging=false;
11745 5326 firing=false;
11746 5326 fclk=0;
11747
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11748
1/4
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if (SIZEflags != 0) init_size_flags();;
11749 5326 }
11750
11751 2075375 bool eWizzrobe::animate(int32_t index)
11752 {
11753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2075375 times.
2075375 if(switch_hooked) return enemy::animate(index);
11754
2/4
✓ Branch 0 taken 2075375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075375 times.
2075375 if(fallclk||drownclk) return enemy::animate(index);
11755
2/2
✓ Branch 0 taken 37967 times.
✓ Branch 1 taken 2037408 times.
2075375 if(dying)
11756 {
11757 37967 return Dead(index);
11758 }
11759
11760
2/2
✓ Branch 0 taken 1970803 times.
✓ Branch 1 taken 66605 times.
2037408 if(clk==0)
11761 {
11762 66605 removearmos(x,y,ffcactivated);
11763 66605 }
11764
11765
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1018188 times.
2037408 if(dmisc1) // Floating
11766 {
11767 1019220 wizzrobe_attack();
11768 1019220 }
11769 else // Teleporting
11770 {
11771
5/6
✓ Branch 0 taken 1011104 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1000017 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1018188 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11772 {
11773 7084 fading=0;
11774 7084 submerge(false);
11775 7084 solid_update(false);
11776 7084 }
11777
8/8
✓ Branch 0 taken 977386 times.
✓ Branch 1 taken 6199 times.
✓ Branch 2 taken 5284 times.
✓ Branch 3 taken 5122 times.
✓ Branch 4 taken 4977 times.
✓ Branch 5 taken 4222 times.
✓ Branch 6 taken 4084 times.
✓ Branch 7 taken 3830 times.
1011104 else switch(clk)
11778 {
11779 case 0:
11780
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5082 times.
6199 if(!dmisc2)
11781 {
11782 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11783 // but should not appear on dungeon walls.
11784
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4669 times.
5082 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11785
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4445 times.
4669 else if (editorflags&ENEMY_FLAG5)
11786 {
11787 //2.10 Windrobe
11788 //randomise location and face Hero
11789 224 int32_t t=0;
11790 224 bool placed=false;
11791
11792
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11793 {
11794
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon())
11795 {
11796 280 x=((zc_oldrand()%12)+2)*16;
11797 280 y=((zc_oldrand()%7)+2)*16;
11798 280 }
11799 else
11800 {
11801 87 x=((zc_oldrand()%14)+1)*16;
11802 87 y=((zc_oldrand()%9)+1)*16;
11803 }
11804
11805
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11806 {
11807 224 placed=true;
11808 224 }
11809
11810 367 ++t;
11811 }
11812
11813
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11814 {
11815
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11816 {
11817 47 dir=down;
11818 47 }
11819 else
11820 {
11821 14 dir=up;
11822 }
11823 61 }
11824 else
11825 {
11826
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11827 {
11828 72 dir=right;
11829 72 }
11830 else
11831 {
11832 91 dir=left;
11833 }
11834 }
11835
11836
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11837 return true;
11838
11839
11840 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11841 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11842 224 }
11843 4445 else place_on_axis(true, dmisc4!=0);
11844 5082 }
11845 else
11846 {
11847 1117 int32_t t=0;
11848 1117 bool placed=false;
11849
11850
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11851 {
11852
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon())
11853 {
11854 1340 x=((zc_oldrand()%12)+2)*16;
11855 1340 y=((zc_oldrand()%7)+2)*16;
11856 1340 }
11857 else
11858 {
11859 1103 x=((zc_oldrand()%14)+1)*16;
11860 1103 y=((zc_oldrand()%9)+1)*16;
11861 }
11862
11863
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11864 {
11865 1117 placed=true;
11866 1117 }
11867
11868 2443 ++t;
11869 }
11870
11871
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11872 {
11873
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11874 {
11875 238 dir=down;
11876 238 }
11877 else
11878 {
11879 148 dir=up;
11880 }
11881 386 }
11882 else
11883 {
11884
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11885 {
11886 340 dir=right;
11887 340 }
11888 else
11889 {
11890 391 dir=left;
11891 }
11892 }
11893
11894
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11895 return true;
11896 }
11897
11898 6199 fading=fade_flicker;
11899 6199 submerge(false);
11900 6199 solid_update(false);
11901 6199 break;
11902
11903 case 64:
11904 5284 fading=0;
11905 5284 charging=true;
11906 5284 break;
11907
11908 case 73:
11909 5122 charging=false;
11910 5122 firing=40;
11911 5122 break;
11912
11913 case 83:
11914 4977 wizzrobe_attack_for_real();
11915 4977 break;
11916
11917 case 119:
11918 4222 firing=false;
11919 4222 charging=true;
11920 4222 break;
11921
11922 case 128:
11923 4084 fading=fade_flicker;
11924 4084 charging=false;
11925 4084 break;
11926
11927 case 146:
11928 3830 fading=fade_invisible;
11929 3830 submerge(true);
11930 3830 solid_update(false);
11931
11932 [[fallthrough]];
11933 default:
11934
4/4
✓ Branch 0 taken 981056 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 975008 times.
✓ Branch 3 taken 6208 times.
981216 if(clk>=(146+zc_max(0,dmisc5)))
11935 6208 clk=-1;
11936
11937 981216 break;
11938 }
11939 }
11940
11941 2037408 return enemy::animate(index);
11942 2075375 }
11943
11944 7900 void eWizzrobe::wizzrobe_attack_for_real()
11945 {
11946
1/2
✓ Branch 0 taken 7900 times.
✗ Branch 1 not taken.
7900 if(wpn==0) // Edited enemies
11947 return;
11948
11949
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5917 times.
7900 if(dmisc2 == 0) //normal weapon
11950 {
11951 5917 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11952 5917 sfx(WAV_WAND,pan(int32_t(x)));
11953 5917 }
11954
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11955 {
11956 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11957 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11958 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11959 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11960 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11961 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11962 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11963 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11964 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11965 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11966 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11967 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11968 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11969 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11970 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11971 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11972 995 sfx(WAV_FIRE,pan(int32_t(x)));
11973
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
11974 else
11975 {
11976
3/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
507 switch(wpn)
11977 {
11978 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
11979
11980 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
11981 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
11982 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
11983 case ewRock: sfx(51,pan(int32_t(x))); break;
11984 68 case ewMagic: sfx(32,pan(int32_t(x))); break;
11985 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
11986 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
11987 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
11988 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
11989 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
11990 420 case ewFlame: sfx(13,pan(int32_t(x))); break;
11991 case ewWind: sfx(32,pan(int32_t(x))); break;
11992 case ewFlame2: sfx(13,pan(int32_t(x))); break;
11993 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
11994 case ewIce: sfx(44,pan(int32_t(x))); break;
11995 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
11996 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
11997
11998 }
11999 }
12000 995 }
12001
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12002 {
12003 971 int32_t bc=0;
12004
12005
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12006 {
12007
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12008 {
12009 5195 ++bc;
12010 5195 }
12011 10497 }
12012
12013
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12014 {
12015 963 int32_t kids = guys.Count();
12016 963 int32_t bats=(zc_oldrand()%3)+1;
12017
12018
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12019 {
12020 // Summon bats (or anything)
12021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(x,y,dmisc3,-10, this->script_UID))
12022 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12023 1965 }
12024
12025 963 sfx(WAV_FIRE,pan(int32_t(x)));
12026 963 }
12027 971 }
12028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12029 {
12030
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies()==0)
12031 {
12032 return;
12033 }
12034
12035 17 int32_t kids = guys.Count();
12036
12037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12038 {
12039 17 int32_t newguys=(zc_oldrand()%3)+1;
12040 17 bool summoned=false;
12041
12042
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12043 {
12044 32 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12045 32 int32_t x2=0;
12046 32 int32_t y2=0;
12047
12048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12049 {
12050 36 x2=16*((zc_oldrand()%12)+2);
12051 36 y2=16*((zc_oldrand()%7)+2);
12052
12053
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12054 {
12055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12056 {
12057 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12058
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12059 {
12060 ((enemy*)guys.spr(kids+i))->fakez = 64;
12061 ((enemy*)guys.spr(kids+i))->z = 0;
12062 }
12063 32 }
12064
12065 32 summoned=true;
12066 32 break;
12067 }
12068 4 }
12069 32 }
12070
12071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12072 {
12073 17 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12074 17 }
12075 17 }
12076 17 }
12077 7900 }
12078
12079
12080 1019220 void eWizzrobe::wizzrobe_attack()
12081 {
12082
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12083 86341 return;
12084
12085
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12086 {
12087 39538 fix_coords();
12088
12089
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12090 {
12091 case 1: //walking
12092
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12093 2644 misc=0;
12094 else
12095 {
12096 10364 clk3=16;
12097
12098
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12099 {
12100 1398 wizzrobe_newdir(0);
12101 1398 }
12102 }
12103
12104 13008 break;
12105
12106 case 2: //phasing
12107 {
12108 3903 int32_t jx=x;
12109 3903 int32_t jy=y;
12110 3903 int32_t jdir=-1;
12111
12112
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12113 {
12114 case 0:
12115 484 jx-=32;
12116 484 jy-=32;
12117 484 jdir=15;
12118 484 break;
12119
12120 case 1:
12121 472 jx+=32;
12122 472 jy-=32;
12123 472 jdir=9;
12124 472 break;
12125
12126 case 2:
12127 482 jx+=32;
12128 482 jy+=32;
12129 482 jdir=11;
12130 482 break;
12131
12132 case 3:
12133 492 jx-=32;
12134 492 jy+=32;
12135 492 jdir=13;
12136 492 break;
12137 }
12138
12139
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12140 {
12141 1140 misc=3;
12142 1140 clk3=32;
12143 1140 dir=jdir;
12144 1140 break;
12145 }
12146 2763 }
12147 [[fallthrough]];
12148 case 3:
12149 3813 dir&=3;
12150 3813 misc=0;
12151 [[fallthrough]];
12152 case 0:
12153 19894 wizzrobe_newdir(64);
12154 [[fallthrough]];
12155 default:
12156
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12157 {
12158
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12159 {
12160 3265 misc=1;
12161 3265 clk3=16;
12162 3265 }
12163 else
12164 {
12165 239 wizzrobe_newdir(64);
12166 239 misc=0;
12167 239 clk3=32;
12168 }
12169 3504 }
12170 else
12171 {
12172 21886 clk3=32;
12173 }
12174
12175 25390 break;
12176 }
12177
12178
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12179 4478 ++misc;
12180 39538 }
12181
12182 932879 --clk3;
12183
12184
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12185 {
12186 case 1:
12187 case 3:
12188 248377 step=1;
12189 248377 break;
12190
12191 case 2:
12192 63903 step=0;
12193 63903 break;
12194
12195 default:
12196 620599 step=0.5;
12197 620599 break;
12198
12199 }
12200
12201 932879 move(step);
12202
12203 // if(d->misc1 && misc<=0 && clk3==28)
12204
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12205 {
12206
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12207 {
12208
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12209 {
12210 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12211 // sfx(WAV_WAND,pan(int32_t(x)));
12212 1928 wizzrobe_attack_for_real();
12213 1928 fclk=30;
12214 1928 }
12215 16835 }
12216 else
12217 {
12218
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12219 {
12220 995 wizzrobe_attack_for_real();
12221 995 fclk=30;
12222 995 }
12223 }
12224 21547 }
12225
12226
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12227 4050 misc=2;
12228
12229
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12230 3441 fix_coords();
12231
12232
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12233 {
12234
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12235 {
12236 83282 --fclk;
12237 83282 }
12238 932879 }
12239
12240 1019220 }
12241
12242 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12243 {
12244 // Wizzrobes shouldn't move to the edge of the screen;
12245 // if they're already there, they should move toward the center
12246
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12247 33 dir=right;
12248
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=224)
12249 4 dir=left;
12250
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12251 2 dir=down;
12252
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=144)
12253 5 dir=up;
12254 else
12255 21487 newdir(4,homing,spw_wizzrobe);
12256 21531 }
12257
12258 2092991 void eWizzrobe::draw(BITMAP *dest)
12259 {
12260 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12261
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1050508 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2092991 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12262 125018 return;
12263
12264 1967973 int32_t tempint=dummy_int[1];
12265 1967973 bool tempbool1=dummy_bool[1];
12266 1967973 bool tempbool2=dummy_bool[2];
12267 1967973 dummy_int[1]=fclk;
12268 1967973 dummy_bool[1]=charging;
12269 1967973 dummy_bool[2]=firing;
12270 1967973 update_enemy_frame();
12271 1967973 dummy_int[1]=tempint;
12272 1967973 dummy_bool[1]=tempbool1;
12273 1967973 dummy_bool[2]=tempbool2;
12274 1967973 enemy::draw(dest);
12275 2092991 }
12276
12277 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12278 203 {
12279 203 fading=fade_flash_die;
12280
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12281 {
12282 3 dir=up;
12283 3 }
12284
12285
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12286 {
12287 dir=left;
12288 }
12289
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12290 203 }
12291
12292 125855 bool eDodongo::animate(int32_t index)
12293 {
12294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12295
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12296 {
12297 3790 return Dead(index);
12298 }
12299
12300
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12301 {
12302 569 removearmos(x,y,ffcactivated);
12303 569 }
12304
12305
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12306 {
12307
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12308 113 hp-=misc; // store bomb's power in misc
12309 10848 }
12310 else
12311 111217 constant_walk(rate,homing,spw_clipright);
12312
12313 122065 hit_width = (dir<=down) ? 16 : 32;
12314 // hysz = (dir>=left) ? 16 : 32;
12315
12316 122065 return enemy::animate(index);
12317 125855 }
12318
12319 125845 void eDodongo::draw(BITMAP *dest)
12320 {
12321 125845 tile=o_tile;
12322
12323
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12324 {
12325 3065 enemy::drawzcboss(dest);
12326 3065 return;
12327 }
12328
12329 122780 update_enemy_frame();
12330 122780 enemy::drawzcboss(dest);
12331
12332
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12333 {
12334 71118 tile+=dummy_int[1]; //second tile is previous tile
12335 71118 xofs-=16; //new xofs change
12336 71118 enemy::drawzcboss(dest);
12337 71118 xofs+=16;
12338 71118 }
12339
12340 125845 }
12341
12342 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12343 {
12344 8218 int32_t wpnId = w->id;
12345 8218 int32_t power = w->power;
12346 8218 int32_t wpnx = w->x;
12347 8218 int32_t wpny = w->y;
12348
12349
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12350 5761 return 0;
12351
12352
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12353 {
12354 case wPhantom:
12355 return 0;
12356
12357 case wFire:
12358 case wBait:
12359 case wWhistle:
12360 case wWind:
12361 case wSSparkle:
12362 case wFSparkle:
12363 return 0;
12364
12365 case wLitBomb:
12366 case wLitSBomb:
12367
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12368 690 return 0;
12369
12370 113 clk2=96;
12371 113 misc=power;
12372
12373
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12374 3 item_set=isSBOMB100;
12375
12376 113 return 1;
12377
12378 case wBomb:
12379 case wSBomb:
12380
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12381 516 return 0;
12382
12383 975 stunclk=160;
12384 975 misc=wpnId; // store wpnId
12385 975 return 1;
12386
12387 case wSword:
12388
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12389 {
12390 88 sfx(WAV_EHIT,pan(int32_t(x)));
12391 88 hp=0;
12392 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12393 88 fading=0; // don't flash
12394 88 return 1;
12395 }
12396
12397 [[fallthrough]];
12398 default:
12399 75 sfx(WAV_CHINK,pan(int32_t(x)));
12400 75 }
12401
12402 75 return 1;
12403 8218 }
12404
12405 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12406 48 {
12407 48 fading=fade_flash_die;
12408 //nets+5180;
12409 48 previous_dir=-1;
12410
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12411 {
12412 1 dir=up;
12413 1 }
12414
12415
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12416 {
12417 dir=left;
12418 }
12419
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12420 48 }
12421
12422 39398 bool eDodongo2::animate(int32_t index)
12423 {
12424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12425
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12426 {
12427 1158 return Dead(index);
12428 }
12429
12430
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12431 {
12432 167 removearmos(x,y,ffcactivated);
12433 167 }
12434
12435
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12436 {
12437
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12438 42 hp-=misc; // store bomb's power in misc
12439 4032 }
12440 else
12441 34208 constant_walk(rate,homing,spw_clipbottomright);
12442
12443 38240 hit_width = (dir<=down) ? 16 : 32;
12444 38240 hit_height = (dir>=left) ? 16 : 32;
12445 38240 hxofs=(dir>=left)?-8:0;
12446 38240 hyofs=(dir<left)?-8:0;
12447
12448 38240 return enemy::animate(index);
12449 39398 }
12450
12451 39601 void eDodongo2::draw(BITMAP *dest)
12452 {
12453
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12454 {
12455 768 enemy::drawzcboss(dest);
12456 768 return;
12457 }
12458
12459 38833 int32_t tempx=xofs;
12460 38833 int32_t tempy=yofs;
12461 38833 update_enemy_frame();
12462 38833 enemy::drawzcboss(dest);
12463 38833 tile+=dummy_int[1]; //second tile change
12464 38833 xofs+=dummy_int[2]; //new xofs change
12465 38833 yofs+=dummy_int[3]; //new yofs change
12466 38833 enemy::drawzcboss(dest);
12467 38833 xofs=tempx;
12468 38833 yofs=tempy;
12469 39601 }
12470
12471 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12472 {
12473 3929 int32_t wpnId = w->id;
12474 3929 int32_t power = w->power;
12475 3929 int32_t wpnx = w->x;
12476 3929 int32_t wpny = w->y;
12477
12478
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12479 2377 return 0;
12480
12481
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12482 {
12483 case wPhantom:
12484 return 0;
12485
12486 case wFire:
12487 case wBait:
12488 case wWhistle:
12489 case wWind:
12490 case wSSparkle:
12491 case wFSparkle:
12492 346 return 0;
12493
12494 case wLitBomb:
12495 case wLitSBomb:
12496
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12497 {
12498 case up:
12499
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12500 77 return 0;
12501
12502 4 break;
12503
12504 case down:
12505
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12506 71 return 0;
12507
12508 6 break;
12509
12510 case left:
12511
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12512 66 return 0;
12513
12514 16 break;
12515
12516 case right:
12517
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12518 65 return 0;
12519
12520 16 break;
12521 }
12522
12523 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12524 // return 0;
12525 42 clk2=96;
12526 42 misc=power;
12527
12528
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12529 item_set=isSBOMB100;
12530
12531 42 return 1;
12532
12533 case wBomb:
12534 case wSBomb:
12535
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12536 {
12537 case up:
12538
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12539 84 return 0;
12540
12541 92 break;
12542
12543 case down:
12544
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12545 113 return 0;
12546
12547 55 break;
12548
12549 case left:
12550
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12551 80 return 0;
12552
12553 105 break;
12554
12555 case right:
12556
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12557 71 return 0;
12558
12559 93 break;
12560 }
12561
12562 345 stunclk=160;
12563 345 misc=wpnId; // store wpnId
12564 345 return 1;
12565
12566 case wSword:
12567
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12568 {
12569 34 sfx(WAV_EHIT,pan(int32_t(x)));
12570 34 hp=0;
12571 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12572 34 fading=0; // don't flash
12573 34 return 1;
12574 }
12575
12576 [[fallthrough]];
12577 default:
12578 158 sfx(WAV_CHINK,pan(int32_t(x)));
12579 158 }
12580
12581 158 return 1;
12582 3929 }
12583
12584 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12585 126 {
12586 //these are here to bypass compiler warnings about unused arguments
12587
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12588 {
12589
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 x = dmisc1 ? 64 : 176;
12590
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 y = 64;
12591 126 }
12592 else { x = X; y = Y; }
12593
12594 //nets+5940;
12595
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12596 {
12597 81 }
12598 else
12599 {
12600
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12601 {
12602 7 flip=1;
12603 7 }
12604 }
12605
12606
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12607 126 clk3=32;
12608 126 clk2=0;
12609 126 clk4=clk;
12610 126 dir=left;
12611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12612 126 }
12613
12614 71899 bool eAquamentus::animate(int32_t index)
12615 {
12616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12617
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12618 2092 return Dead(index);
12619
12620 // fbx=x+((id==eRAQUAM)?4:-4);
12621
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12622 {
12623 317 removearmos(x,y,ffcactivated);
12624 317 }
12625
12626 69807 fbx=x;
12627
12628 /*
12629 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12630 {
12631 fbx+=16;
12632 }
12633 */
12634
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12635 {
12636 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12637 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12638 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12639 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12640 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12641 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12642 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12643 450 }
12644
12645
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 21018 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12646 {
12647 345 clk3=32;
12648 345 }
12649
12650
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12651 {
12652 1117 int32_t d2=(zc_oldrand()%3)+1;
12653
12654
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12655 {
12656 752 dir=d2;
12657 752 }
12658
12659
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 732 times.
1117 if(dmisc1)
12660 {
12661
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(x<=40)
12662 {
12663 38 dir=right;
12664 38 }
12665
12666
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(x>=104)
12667 {
12668 dir=left;
12669 }
12670 385 }
12671 else
12672 {
12673
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(x<=136)
12674 {
12675 21 dir=right;
12676 21 }
12677
12678
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(x>=200)
12679 {
12680 34 dir=left;
12681 34 }
12682 }
12683 1117 }
12684
12685
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12686 {
12687
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12688 {
12689 4546 x-=1;
12690 4546 }
12691 else
12692 {
12693 3995 x+=1;
12694 }
12695 8541 }
12696
12697 69807 clk4=(clk4+1)%256;
12698
12699 69807 return enemy::animate(index);
12700 71899 }
12701
12702 72310 void eAquamentus::draw(BITMAP *dest)
12703 {
12704
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12705 {
12706 44994 xofs=(dmisc1?-16:0);
12707
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12708
12709
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12710 {
12711 1312 xofs=0;
12712 1312 enemy::draw(dest);
12713 1312 }
12714 else
12715 {
12716 43682 drawblock(dest,15);
12717 }
12718 44994 }
12719 else
12720 {
12721 27316 int32_t xblockofs=((dmisc1)?-16:16);
12722 27316 xofs=0;
12723
12724
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12725 {
12726 1462 enemy::draw(dest);
12727 1462 return;
12728 }
12729
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12730 {
12731 // face (0=firing, 2=resting)
12732 25854 tile=o_tile+((clk3>0)?0:2);
12733 25854 enemy::draw(dest);
12734 // tail (
12735 25854 tile=o_tile+((clk&16)?1:3);
12736 25854 xofs=xblockofs;
12737 25854 enemy::draw(dest);
12738 // body
12739 25854 yofs+=16;
12740 25854 xofs=0;
12741 25854 tile=o_tile+((clk&16)?20:22);
12742 25854 enemy::draw(dest);
12743 25854 xofs=xblockofs;
12744 25854 tile=o_tile+((clk&16)?21:23);
12745 25854 enemy::draw(dest);
12746 25854 yofs-=16;
12747 25854 }
12748 else enemy::draw(dest);
12749 }
12750 72310 }
12751
12752 23834 bool eAquamentus::hit(weapon *w)
12753 {
12754
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12755
12756
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12757 {
12758 case wBeam:
12759 case wRefBeam:
12760 case wMagic:
12761 4201 hit_height=32;
12762 4201 }
12763
12764
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12765 23834 hit_height=16;
12766 23834 return ret;
12767
12768 23834 }
12769
12770 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12771 93 {
12772
12773
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12774 {
12775
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 x = 128;
12776
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 y = 48;
12777 93 }
12778 else { x = X; y = Y; }
12779
12780 93 Clk=Clk;
12781
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12782 {
12783 clk=0;
12784 superman = 1;
12785 fading=fade_flicker;
12786 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12787 }
12788
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12789 {
12790 42 clk=0;
12791 42 }
12792 93 hxofs=-16;
12793 93 hit_width=48;
12794 93 clk4=0;
12795
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12796
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12797
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12798
12799 //nets+5340;
12800 93 }
12801
12802 70891 bool eGohma::animate(int32_t index)
12803 {
12804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12805
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12806 1226 return Dead(index);
12807
12808
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12809 {
12810
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12811 {
12812 35 clk4=0;
12813 35 superman=0;
12814 35 fading=0;
12815 35 clk=0;
12816
12817 35 }
12818 1 else return enemy::animate(index);
12819 35 }
12820
12821
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12822 {
12823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(ffcactivated-1);
12824 else
12825 {
12826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12827 350 did_armos = false;
12828 350 removearmos(x,y);
12829 350 did_armos = false;
12830
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12831 }
12832 350 }
12833
12834
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12835
12836 // Movement clk must be separate from animation clk because of the Clock item
12837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12838 68878 clk4++;
12839
12840
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12841 {
12842
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12843 546 dir^=1;
12844 else
12845 486 dir=zc_oldrand()%3+1;
12846 1032 }
12847
12848
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12849 {
12850
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12851 {
12852 case 1:
12853 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12854 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12855 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12856 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12857 235 break;
12858
12859 default:
12860
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12861 {
12862 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12863 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12864 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12865 754 }
12866
12867 882 break;
12868 }
12869 1117 }
12870
12871
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12872 {
12873
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12874 {
12875 290 FireBreath(true);
12876 290 }
12877 2215 }
12878
12879
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12880 34479 move((zfix)1);
12881
12882
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12883 150 clk3=0;
12884
12885 68878 return enemy::animate(index);
12886 70891 }
12887
12888 70889 void eGohma::draw(BITMAP *dest)
12889 {
12890 70889 tile=o_tile;
12891
12892
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12893 {
12894 2012 enemy::drawzcboss(dest);
12895 2012 return;
12896 }
12897
12898
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12899 {
12900 ///if ( do_animation )
12901 //Yuck. Gohma can just not have this capability right now.
12902 // left side
12903 53472 xofs=-16;
12904 53472 flip=0;
12905 // if(clk&16) tile=180;
12906 // else { tile=182; flip=1; }
12907 53472 tile+=(3*((clk&48)>>4));
12908 53472 enemy::drawzcboss(dest);
12909
12910 // right side
12911 53472 xofs=16;
12912 // tile=(180+182)-tile;
12913 53472 tile=o_tile;
12914 53472 tile+=(3*((clk&48)>>4))+2;
12915 53472 enemy::drawzcboss(dest);
12916
12917 // body
12918 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12919 53472 tile=o_tile;
12920
12921 // tile+=(3*((clk&24)>>3))+2;
12922
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12923 2975 tile+=7;
12924
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12925 15890 tile+=10;
12926
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12927 2051 tile+=7;
12928 else
12929 32556 tile+=((clk3-132)&24)?4:1;
12930
12931 53472 enemy::drawzcboss(dest);
12932
12933 53472 }
12934 else
12935 {
12936 // left side
12937 15405 xofs=-16;
12938 15405 flip=0;
12939
12940
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12941 {
12942 7790 tile+=2;
12943 7790 flip=1;
12944 7790 }
12945
12946 15405 enemy::draw(dest);
12947
12948 // right side
12949 15405 tile=o_tile;
12950 15405 xofs=16;
12951
12952
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12953
12954 // tile=(180+182)-tile;
12955 15405 enemy::draw(dest);
12956
12957 // body
12958 15405 tile=o_tile;
12959 15405 xofs=0;
12960
12961
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12962 912 tile+=4;
12963
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12964 4882 tile+=5;
12965
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12966 585 tile+=4;
12967 9026 else tile+=((clk3-132)&8)?3:1;
12968
12969 15405 enemy::draw(dest);
12970
12971 }
12972 70889 }
12973
12974 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12975 {
12976 578 int32_t wpnId = w->id;
12977 578 int32_t power = w->power;
12978 578 int32_t wpnx = w->x;
12979 578 int32_t wpnDir = w->dir;
12980 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12981
12982
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12983 {
12984
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12985 {
12986 93 sfx(WAV_CHINK,pan(int32_t(x)));
12987 93 return 1;
12988 }
12989 328 }
12990
12991 485 return enemy::takehit(w, realweap);
12992 578 }
12993
12994 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12995 327 {
12996 327 count_enemy=(id==(id&0xFFF));
12997 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
12998
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
12999 327 }
13000
13001 124050 bool eLilDig::animate(int32_t index)
13002 {
13003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13004
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13005 4410 return Dead(index);
13006
13007
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13008 {
13009 7105 removearmos(x,y,ffcactivated);
13010 7105 }
13011
13012
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13013 {
13014
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13015 1161 step+=0.25;
13016 38646 }
13017
13018 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13019 119640 return enemy::animate(index);
13020 124050 }
13021
13022 124268 void eLilDig::draw(BITMAP *dest)
13023 {
13024 124268 tile = o_tile;
13025 // tile = 160;
13026 124268 int32_t fdiv = frate/4;
13027
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13028
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13029 124268 efrate:((clk>=(frate>>1))?1:0);
13030
13031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13032 {
13033
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13034 {
13035
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13036 {
13037 case up: //u
13038 11370 flip=0;
13039 11370 break;
13040
13041 case l_up: //d
13042 10699 flip=0;
13043 10699 tile+=4;
13044 10699 break;
13045
13046 case l_down: //l
13047 10722 flip=0;
13048 10722 tile+=8;
13049 10722 break;
13050
13051 case left: //r
13052 12015 flip=0;
13053 12015 tile+=12;
13054 12015 break;
13055
13056 case r_down: //ul
13057 10070 flip=0;
13058 10070 tile+=20;
13059 10070 break;
13060
13061 case down: //ur
13062 9554 flip=0;
13063 9554 tile+=24;
13064 9554 break;
13065
13066 case r_up: //dl
13067 8255 flip=0;
13068 8255 tile+=28;
13069 8255 break;
13070
13071 case right: //dr
13072 10033 flip=0;
13073 10033 tile+=32;
13074 10033 break;
13075 }
13076
13077 91457 tile+=f2;
13078 91457 }
13079 else
13080 {
13081 32811 tile+=(clk>=6)?1:0;
13082 }
13083 124268 }
13084
13085 124268 enemy::draw(dest);
13086 124268 }
13087
13088 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13089 80 {
13090
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13091 80 }
13092
13093 29662 bool eBigDig::animate(int32_t index)
13094 {
13095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13097 return Dead(index);
13098
13099
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13100 {
13101 4104 removearmos(x,y,ffcactivated);
13102 4104 }
13103
13104
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13105 {
13106 case 0:
13107 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13108 29534 break;
13109
13110 case 1:
13111 64 ++misc;
13112 64 break;
13113
13114 case 2:
13115
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13116 {
13117 111 addenemy(x,y,dmisc1+0x1000,-15);
13118 111 }
13119
13120
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13121 {
13122 30 addenemy(x,y,dmisc2+0x1000,-15);
13123 30 }
13124
13125
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13126 {
13127 30 addenemy(x,y,dmisc3+0x1000,-15);
13128 30 }
13129
13130
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13131 {
13132 30 addenemy(x,y,dmisc4+0x1000,-15);
13133 30 }
13134
13135
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13136 {
13137 2 guycarryingitem = guys.Count()-1;
13138 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13139 2 itemguy = false;
13140 2 }
13141
13142 64 stop_bgsfx(index);
13143
13144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13145
13146 64 return true;
13147 }
13148
13149 29598 return enemy::animate(index);
13150 29662 }
13151
13152 29658 void eBigDig::draw(BITMAP *dest)
13153 {
13154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13155 {
13156 update_enemy_frame();
13157 xofs-=8;
13158 yofs-=8;
13159 drawblock(dest,15);
13160 xofs+=8;
13161 yofs+=8;
13162 return;
13163 }
13164
13165 29658 tile = o_tile;
13166 29658 int32_t fdiv = frate/4;
13167
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13168
13169
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13170 29658 efrate:((clk>=(frate>>1))?1:0);
13171
13172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13173 {
13174
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13175 {
13176
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13177 {
13178 case up: //u
13179 1688 flip=0;
13180 1688 break;
13181
13182 case l_up: //d
13183 1684 flip=0;
13184 1684 tile+=8;
13185 1684 break;
13186
13187 case l_down: //l
13188 2031 flip=0;
13189 2031 tile+=40;
13190 2031 break;
13191
13192 case left: //r
13193 1910 flip=0;
13194 1910 tile+=48;
13195 1910 break;
13196
13197 case r_down: //ul
13198 2041 flip=0;
13199 2041 tile+=80;
13200 2041 break;
13201
13202 case down: //ur
13203 2043 flip=0;
13204 2043 tile+=88;
13205
13206 2043 break;
13207
13208 case r_up: //dl
13209 1514 flip=0;
13210 1514 tile+=120;
13211 1514 break;
13212
13213 case right: //dr
13214 2241 flip=0;
13215 2241 tile+=128;
13216 2241 break;
13217 }
13218
13219 16161 tile+=(f2*2);
13220 16161 }
13221 else
13222 {
13223 13497 tile+=(f2)?0:2;
13224 13497 flip=(clk&1)?1:0;
13225 }
13226 29658 }
13227
13228 29658 xofs-=8;
13229 29658 yofs-=8;
13230 29658 drawblock(dest,15);
13231 29658 xofs+=8;
13232 29658 yofs+=8;
13233 29658 }
13234
13235 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13236 {
13237 869 int32_t wpnId = w->id;
13238
13239
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13240 64 misc=1;
13241
13242 869 return 0;
13243 }
13244
13245 80 void eBigDig::init_size_flags()
13246 {
13247 80 SIZEflags = d->SIZEflags;
13248
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13249 // al_trace("Enemy txsz:%i\n", txsz);
13250
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13252 80 else hit_width = 32;
13253
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13254 80 else hit_height = 32;
13255
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13256 80 else hzsz = 16; // hard to jump.
13257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13258 80 else hxofs = -8;
13259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13260 80 else hyofs = -8;
13261 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13262
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13263
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
13264 {
13265 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13266 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13267 }
13268
13269
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13270 80 }
13271
13272 /*
13273 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13274 {
13275 hxofs=hyofs=8;
13276 hzsz=16; //can't be jumped.
13277 clk2=70;
13278 misc=-1;
13279 mainguy=!getmapflag();
13280 }
13281
13282 bool eGanon::animate(int32_t index)
13283 {
13284 if(switch_hooked) return enemy::animate(index);
13285 if(dying)
13286
13287 return Dead(index);
13288
13289 if(clk==0)
13290 {
13291 removearmos(x,y,ffcactivated);
13292 }
13293
13294 switch(misc)
13295 {
13296 case -1:
13297 misc=0;
13298
13299 case 0:
13300 if(++clk2>72 && !(zc_oldrand()&3))
13301 {
13302 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13303 sfx(wpnsfx(wpn),pan(int32_t(x)));
13304 clk2=0;
13305 }
13306
13307 Stunclk=0;
13308 constant_walk(rate,homing,spw_none);
13309 break;
13310
13311 case 1:
13312 case 2:
13313 if(--Stunclk<=0)
13314 {
13315 int32_t r=zc_oldrand();
13316
13317 if(r&1)
13318 {
13319 y=96;
13320
13321 if(r&2)
13322 x=160;
13323 else
13324 x=48;
13325
13326 if(tooclose(x,y,48))
13327 x=208-x;
13328 }
13329
13330 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13331 //{
13332 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13333 // }
13334 // else
13335 // {
13336 loadpalset(csBOSS,pSprite(d->bosspal));
13337 // }
13338 misc=0;
13339 }
13340
13341 break;
13342
13343 case 3:
13344 {
13345 if(hclk>0)
13346 break;
13347
13348 misc=4;
13349 clk=0;
13350 hxofs=1000;
13351 loadpalset(9,pSprite(spPILE));
13352 music_stop();
13353 stop_sfx(WAV_ROAR);
13354
13355 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13356
13357 sfx(WAV_GANON);
13358 //Ganon's dustpile; fall in sideview. -Z
13359 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13360 dustpile->linked_parent = eeGANON;
13361 setmapflag();
13362 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13363 break;
13364 }
13365
13366 case 4:
13367 if(clk>=80)
13368 {
13369 misc=5;
13370
13371 if(getmapflag())
13372 {
13373 game->lvlitems[dlevel]|=liBOSS;
13374 //play_DmapMusic();
13375 playLevelMusic();
13376 return true;
13377 }
13378
13379 sfx(WAV_CLEARED);
13380 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13381 setmapflag();
13382 }
13383
13384 break;
13385 }
13386
13387 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13388 //{
13389 //if ( current_item_id(itype_amulet,false) >= 2 )
13390 //{
13391 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13392 //}
13393 //}
13394
13395
13396 return enemy::animate(index);
13397 }
13398
13399
13400 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13401 {
13402 //these are here to bypass compiler warnings about unused arguments
13403 int32_t wpnId = w->id;
13404 int32_t power = w->power;
13405 int32_t enemyHitWeapon = w->parentitem;
13406
13407 switch(misc)
13408 {
13409 case 0:
13410 {
13411 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13412 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13413 return 0;
13414
13415 //if we are not using the new defences, just reduce his HP
13416 if (!(editorflags & ENEMY_FLAG14))
13417 {
13418 hp-=power;
13419 if(hp>0)
13420 {
13421 misc=1;
13422 Stunclk=64;
13423 }
13424 else
13425 {
13426 loadpalset(csBOSS,pSprite(spBROWN));
13427 misc=2;
13428 Stunclk=284;
13429 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13430 }
13431
13432 sfx(WAV_EHIT,pan(int32_t(x)));
13433
13434 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13435
13436 return 1;
13437 }
13438 //otherwise, resolve his defence.
13439 else
13440 {
13441 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13442 if(hp>0)
13443 {
13444 misc=1;
13445 Stunclk=64;
13446 }
13447 else
13448 {
13449 loadpalset(csBOSS,pSprite(spBROWN));
13450 misc=2;
13451 Stunclk=284;
13452 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13453 }
13454
13455 sfx(WAV_EHIT,pan(int32_t(x)));
13456
13457 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13458
13459
13460 return 1;
13461 }
13462 }
13463 case 2:
13464 {
13465 if
13466 (
13467 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13468 || //or nothing specified, use silver arrows+
13469 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13470 )
13471 return 0;
13472 {
13473 misc=3;
13474 hclk=81;
13475 loadpalset(9,pSprite(spBROWN));
13476 return 1;
13477 }
13478
13479 }
13480 }
13481
13482 return 0;
13483 }
13484
13485 void eGanon::draw(BITMAP *dest)
13486 {
13487 switch(misc)
13488 {
13489 case 0:
13490 if((clk&3)==3)
13491 tile=(zc_oldrand()%5)*2+o_tile;
13492
13493 if(db!=999)
13494 break;
13495
13496 case 2:
13497 if(Stunclk<64 && (Stunclk&1) )
13498 {
13499 if
13500 (
13501 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13502 ||
13503 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13504 )
13505 {
13506 goto ganon_draw; //draw his weapons if we can see him
13507 }
13508 break;
13509 }
13510
13511 case -1:
13512 tile=o_tile;
13513
13514 //fall through
13515 case 1:
13516 case 3:
13517 ganon_draw:
13518 drawblock(dest,15);
13519 break;
13520
13521 case 4:
13522 draw_guts(dest);
13523 draw_flash(dest);
13524 break;
13525 }
13526
13527 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13528 {
13529 if
13530 (
13531 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13532 ||
13533 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13534 )
13535 {
13536 draw_guts(dest); //makes his shots visible, but not him
13537 draw_flash(dest);
13538 }
13539 }
13540 }
13541
13542 void eGanon::draw_guts(BITMAP *dest)
13543 {
13544 int32_t c = zc_min(clk>>3,8);
13545 tile = clk<24 ? 74 : 75;
13546 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13547 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13548 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13549 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13550 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13551 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13552 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13553 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13554 }
13555
13556 void eGanon::draw_flash(BITMAP *dest)
13557 {
13558
13559 int32_t c = clk-(clk>>2);
13560 cs = (frame&3)+6;
13561 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13562 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13563 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13564 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13565 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13566 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13567 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13568 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13569 }
13570 */
13571
13572 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13573 13 {
13574 13 hxofs=hyofs=8;
13575
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13576 {
13577 hxofs = 4;
13578 hyofs = 4;
13579 hit_width = 24;
13580 hit_height = 24;
13581 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
13582 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
13583 }
13584 13 hzsz=16; //can't be jumped.
13585 13 clk2=70;
13586 13 misc=-1;
13587
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
13588 13 }
13589
13590 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13591 {
13592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13593
13594 return Dead(index);
13595
13596
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13597 {
13598 72 removearmos(x,y,ffcactivated);
13599 72 }
13600
13601
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13602 {
13603 case -1:
13604 13 misc=0;
13605 [[fallthrough]];
13606 case 0:
13607
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13608 {
13609 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13610 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13611 173 clk2=0;
13612 173 }
13613
13614 12693 Stunclk=0;
13615 12693 constant_walk(rate,homing,spw_none);
13616 12693 break;
13617
13618 case 1:
13619 case 2:
13620
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13621 {
13622 41 int32_t r=zc_oldrand();
13623
13624
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13625 {
13626 17 y=96;
13627
13628
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13629 6 x=160;
13630 else
13631 11 x=48;
13632
13633
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13634 8 x=208-x;
13635 17 }
13636
13637 41 loadpalset(csBOSS,pSprite(d->bosspal));
13638 41 misc=0;
13639 41 }
13640
13641 3607 break;
13642
13643 case 3:
13644 {
13645
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13646 972 break;
13647
13648 12 misc=4;
13649 12 clk=0;
13650 12 hxofs=1000;
13651 12 loadpalset(9,pSprite(spPILE));
13652 12 music_stop();
13653 12 stop_sfx(WAV_ROAR);
13654
13655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13656
13657 12 sfx(WAV_GANON);
13658 //Ganon's dustpile; fall in sideview. -Z
13659 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13660 //dustpile->miscellaneous[31] = eeGANON;
13661
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13662 12 item *dustpile = NULL;
13663 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13664 12 dustpile = (item *)items.spr(items.Count() - 1);
13665 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13666 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
13667 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13668 12 break;
13669 }
13670
13671 case 4:
13672
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13673 {
13674 12 misc=5;
13675
13676 //game->lvlitems[dlevel]|=liBOSS;
13677
13678 12 sfx(WAV_CLEARED);
13679 //Add the big TF over the ashes!
13680
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13681 {
13682 24 item *ashes = (item*)items.spr(q);
13683
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13684 {
13685 //Z_scripterrlog("Found correct dustpile!\n");
13686
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13687 12 item *bigtriforce = NULL;
13688 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13689 12 bigtriforce->linked_parent = eeGANON;
13690 12 }
13691 24 }
13692 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13693 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
13694 12 }
13695
13696 960 break;
13697 10 case 5: return true;
13698 }
13699
13700 18244 return enemy::animate(index);
13701 18254 }
13702
13703
13704 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13705 {
13706 //these are here to bypass compiler warnings about unused arguments
13707 964 int32_t wpnId = w->id;
13708 964 int32_t power = w->power;
13709 964 int32_t enemyHitWeapon = w->parentitem;
13710
13711
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13712 {
13713 case 0:
13714
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13715 31 return 0;
13716
13717 53 hp-=power;
13718
13719
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13720 {
13721 41 misc=1;
13722 41 Stunclk=64;
13723 41 }
13724 else
13725 {
13726 12 loadpalset(csBOSS,pSprite(spBROWN));
13727 12 misc=2;
13728 12 Stunclk=284;
13729 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13730 }
13731
13732 53 sfx(WAV_EHIT,pan(int32_t(x)));
13733
13734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13735
13736 53 return 1;
13737
13738 case 2:
13739
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13740 154 return 0;
13741
13742 12 misc=3;
13743 12 hclk=81;
13744 12 loadpalset(9,pSprite(spBROWN));
13745 12 return 1;
13746 }
13747
13748 714 return 0;
13749 964 }
13750
13751 20776 void eGanon::draw(BITMAP *dest)
13752 {
13753
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13754 {
13755 case 0:
13756
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13757 3169 tile=(zc_oldrand()%5)*2+o_tile;
13758
13759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13760 {
13761
13762 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13763 {
13764 int odraw = drawstyle;
13765 drawstyle = 2;
13766 drawblock(dest,15);
13767 drawstyle = odraw;
13768 }
13769 else
13770 {
13771 drawblock(dest,15);
13772 }
13773 break;
13774
13775 }
13776
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13777 {
13778 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13779 {
13780 int odraw = drawstyle;
13781 drawstyle = 2;
13782 drawblock(dest,15);
13783 drawstyle = odraw;
13784 }
13785 else
13786 {
13787 drawblock(dest,15);
13788 }
13789 break;
13790 }
13791
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13792 12680 break;
13793 [[fallthrough]];
13794 case 2:
13795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13796 break;
13797 [[fallthrough]];
13798 case -1:
13799 3518 tile=o_tile;
13800
13801 [[fallthrough]];
13802 case 1:
13803 case 3:
13804 7126 drawblock(dest,15);
13805 7126 break;
13806
13807 case 4:
13808 960 draw_guts(dest);
13809 960 draw_flash(dest);
13810 960 break;
13811 }
13812 20776 }
13813
13814 960 void eGanon::draw_guts(BITMAP *dest)
13815 {
13816
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13817 960 tile = clk<24 ? 74 : 75;
13818 960 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13819 960 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13820 960 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13821 960 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13822 960 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13823 960 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13824 960 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13825 960 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13826 960 }
13827
13828 960 void eGanon::draw_flash(BITMAP *dest)
13829 {
13830
13831 960 int32_t c = clk-(clk>>2);
13832 960 cs = (frame&3)+6;
13833 960 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13834 960 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13835 960 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13836 960 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13837 960 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13838 960 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13839 960 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13840 960 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13841 960 }
13842
13843 15 void getBigTri(int32_t id2)
13844 {
13845 /*
13846 *************************
13847 * BIG TRIFORCE SEQUENCE *
13848 *************************
13849 0 BIGTRI out, WHITE flash in
13850 4 WHITE flash out, PILE cset white
13851 8 WHITE in
13852 ...
13853 188 WHITE out
13854 191 PILE cset red
13855 200 top SHUTTER opens
13856 209 bottom SHUTTER opens
13857 */
13858 15 sfx(itemsbuf[id2].playsound);
13859 15 guys.clear();
13860
13861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13862 {
13863 game->lvlitems[dlevel]|=liTRIFORCE;
13864 }
13865
13866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13867
13868 15 draw_screen(tmpscr);
13869
13870
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13871 {
13872
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13873 {
13874
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13875 {
13876 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13877 225 }
13878 15 }
13879
13880
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13881 {
13882
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13883 {
13884
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13885 {
13886 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13887 16200 }
13888 1080 }
13889
13890 360 refreshpal=true;
13891 360 }
13892
13893
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13894 {
13895
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
13896 else loadlvlpal(0xB);
13897 360 }
13898
13899
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13900 {
13901 15 loadpalset(9,pSprite(spPILE));
13902 15 }
13903
13904 2880 advanceframe(true);
13905 2880 }
13906
13907 //play_DmapMusic();
13908 15 playLevelMusic();
13909
13910
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && currscr < 128)
13911 {
13912 2 Hero.dowarp(1,0); //side warp
13913 2 }
13914 15 }
13915
13916 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13917 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13918 618 {
13919
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13920 {
13921
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 x=128;
13922
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 y=48;
13923 618 }
13924 //else { x = X; y = Y; }
13925
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13926 618 superman=1;
13927 618 fading=fade_invisible;
13928 618 hxofs=1000;
13929 618 segcnt=clk;
13930 618 segid=Id|0x1000;
13931 618 clk=0;
13932
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13933
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13934 618 tile=o_tile;
13935 618 hitdir = -1;
13936 618 stickclk = 0;
13937
13938 /*
13939 if (get_qr(qr_NEWENEMYTILES))
13940 {
13941 tile=nets+1220;
13942 }
13943 else
13944 {
13945 tile=57;
13946 }
13947 */
13948 618 }
13949
13950 244844 bool eMoldorm::animate(int32_t index)
13951 {
13952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13953 244844 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
13954
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13955 {
13956 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13957 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13958 28475 }
13959
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13960 {
13961 562 stickclk = 0;
13962 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13963 562 }
13964
13965
13966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13967 {
13968 244844 removearmos(x,y,ffcactivated);
13969 244844 }
13970
13971
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13972 {
13973
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13974 {
13975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13976 129 never_return(index);
13977
13978
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13979 129 leave_item();
13980
13981 129 stop_bgsfx(index);
13982 129 return true;
13983 }
13984 2322 }
13985 else
13986 {
13987
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13988 stunclk=0;
13989 242393 constant_walk_8_old(rate,homing,spw_floater);
13990
13991
13992 242393 misc=dir;
13993
13994 // If any higher-numbered segments were killed, segcnt can be too high,
13995 // leading to a crash
13996
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13997 segcnt=guys.Count()-index-1;
13998
13999
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
14000 {
14001 1122281 enemy* segment=((enemy*)guys.spr(i));
14002
14003 // More validation - if segcnt was wrong, this may not
14004 // actually be a Moldorm segment
14005
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
14006 {
14007 segcnt=i-index-1;
14008 break;
14009 }
14010
14011
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
14012 {
14013 242669 x=segment->x;
14014 242669 y=segment->y;
14015 242669 }
14016
14017 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14018 //Script your own blasted segmented bosses!! -Z
14019 1122281 segment->parent_script_UID = this->script_UID;
14020
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
14021 {
14022 217733 segment->dummy_int[1]=2;
14023 217733 }
14024 else
14025 {
14026 904548 segment->dummy_int[1]=1;
14027 }
14028
14029
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
14030 {
14031 242669 segment->dummy_int[1]=0;
14032 242669 }
14033
14034
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
14035 {
14036 1016 int32_t offset=1;
14037
14038
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
14039 {
14040 // Triple-check
14041
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
14042 {
14043 segcnt=j-index+1; // Add 1 because of --segcnt below
14044 break;
14045 }
14046 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14047 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14048 1480 }
14049
14050 1016 segment->hclk=33;
14051 1016 --segcnt;
14052 1016 --i; // Recheck the same index in case multiple segments died at once
14053 1016 }
14054 1122281 }
14055
14056
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
14057 {
14058 129 clk2=19;
14059
14060 129 x=guys.spr(index+1)->x;
14061 129 y=guys.spr(index+1)->y;
14062 129 }
14063 }
14064
14065 244715 return false;
14066 244844 }
14067
14068 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14069 3150 {
14070
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
14071 {
14072
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 x=128;
14073
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 y=48;
14074 3150 }
14075
14076
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14077 3150 hyofs=4;
14078 3150 hit_width=hit_height=8;
14079 3150 hxofs=1000;
14080 3150 mainguy=count_enemy=false;
14081 3150 parentclk = 0;
14082 3150 bgsfx=-1;
14083
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
14084 //deadsfx = WAV_EDEAD;
14085 3150 isCore = false;
14086 3150 }
14087
14088 1138024 bool esMoldorm::animate(int32_t index)
14089 {
14090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
14091 // Shouldn't be possible, but better to be sure
14092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
14093 dying=true;
14094
14095
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
14096 {
14097
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
14098 15743 item_set=0;
14099
14100 15743 return Dead(index);
14101 }
14102
14103
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
14104 {
14105 1017204 hxofs=4;
14106 1017204 step=((enemy*)guys.spr(index-1))->step;
14107
14108
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
14109 {
14110 70455 misc=dir;
14111 70455 dir=((enemy*)guys.spr(index-1))->misc;
14112 //do alignment, as in parent's animation :-/ -DD
14113 70455 x.doFloor();
14114 70455 y.doFloor();
14115 70455 }
14116
14117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
14118 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14119
14120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
14121 {
14122 1017204 sprite::move(step);
14123 1017204 }
14124 1017204 }
14125
14126 1122281 return enemy::animate(index);
14127 1138024 }
14128
14129 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14130 {
14131
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
14132 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14133
14134 453 return 0;
14135 2683 }
14136
14137 1155313 void esMoldorm::draw(BITMAP *dest)
14138 {
14139 1155313 tile=o_tile;
14140 1155313 int32_t fdiv = frate/4;
14141
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14142
14143
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14144 1155313 efrate:((clk>=(frate>>1))?1:0);
14145
14146
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
14147 {
14148 1043930 tile+=dummy_int[1]*40;
14149
14150
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
14151 {
14152 102730 flip=0;
14153
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14154
14155
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
14156 tile+=4;
14157 102730 }
14158 else
14159 {
14160
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
14161 {
14162 case up: //u
14163 96530 flip=0;
14164 96530 break;
14165
14166 case l_up: //d
14167 134534 flip=0;
14168 134534 tile+=4;
14169 134534 break;
14170
14171 case l_down: //l
14172 113426 flip=0;
14173 113426 tile+=8;
14174 113426 break;
14175
14176 case left: //r
14177 124800 flip=0;
14178 124800 tile+=12;
14179 124800 break;
14180
14181 case r_down: //ul
14182 101314 flip=0;
14183 101314 tile+=20;
14184 101314 break;
14185
14186 case down: //ur
14187 99043 flip=0;
14188 99043 tile+=24;
14189 99043 break;
14190
14191 case r_up: //dl
14192 131794 flip=0;
14193 131794 tile+=28;
14194 131794 break;
14195
14196 case right: //dr
14197 139759 flip=0;
14198 139759 tile+=32;
14199 139759 break;
14200 }
14201 }
14202
14203 1043930 tile+=f2;
14204 1043930 }
14205
14206
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
14207 1049046 enemy::draw(dest);
14208 1155313 }
14209
14210 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14211 420 {
14212
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
14213 {
14214
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 x=64;
14215
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 y=80;
14216 420 }
14217 //else { x = X; y = Y; }
14218 //byte legaldirs = 0;
14219 420 int32_t incr = 16;
14220 //int32_t possiiblepos = 0;
14221 //int32_t positions[8] = {0};
14222
14223 //Don't spawn in pits.
14224
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
14225 {
14226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
14227 {
14228 //move if we spawn over a pit
14229 //check each direction
14230
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14231 {
14232
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14233 }
14234
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14235 {
14236
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
14237 }
14238
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14239 {
14240
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14241 }
14242
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14243 {
14244
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
14245 }
14246
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14247 {
14248 y -= incr; break;
14249 }
14250
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14251 {
14252 y+=incr; break;
14253 }
14254
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14255 {
14256
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14257 }
14258
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14259 {
14260 x+=incr; y+=incr; break;
14261 }
14262 34 else continue;
14263
14264 }
14265
14266 105 }
14267
14268 420 dir=up;
14269 420 superman=1;
14270 420 fading=fade_invisible;
14271 420 hxofs=1000;
14272 420 segcnt=clk;
14273 420 clk=0;
14274 //set up move history
14275
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14276
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14277 420 }
14278
14279 236907 bool eLanmola::animate(int32_t index)
14280 {
14281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14282
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14283 {
14284 40196 removearmos(x,y,ffcactivated);
14285 40196 }
14286
14287
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14288 {
14289
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14290 {
14291
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14292 86 leave_item();
14293
14294 189 stop_bgsfx(index);
14295 189 return true;
14296 }
14297
14298 3402 return false;
14299 }
14300
14301
14302 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14303 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14304 //I've added a complete movement history to this enemy to compensate -DD
14305 233316 constant_walk(rate,homing,spw_none);
14306 233316 prevState.pop_front();
14307 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14308
14309 // This could cause a crash with Moldorms. I didn't see the same problem
14310 // with Lanmolas, but it looks like it ought to be possible, so here's
14311 // the same solution. - Saf
14312
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14313 segcnt=guys.Count()-index-1;
14314
14315
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14316 {
14317 966396 enemy* segment=((enemy*)guys.spr(i));
14318
14319 // More validation in case segcnt is wrong
14320
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14321 {
14322 segcnt=i-index-1;
14323 break;
14324 }
14325
14326 966396 segment->o_tile=o_tile;
14327 966396 segment->parent_script_UID = this->script_UID;
14328
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14329 {
14330 195700 segment->dummy_int[1]=1; //tail
14331 195700 }
14332 else
14333 {
14334 770696 segment->dummy_int[1]=0;
14335 }
14336
14337
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14338 {
14339
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14340 {
14341 // Triple-check
14342
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14343 {
14344 segcnt=j-index+1; // Add 1 because of --segcnt below
14345 break;
14346 }
14347 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14348 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14349 1961 }
14350
14351 1169 ((enemy*)guys.spr(i))->hclk=33;
14352 1169 --segcnt;
14353 1169 --i; // Recheck the same index in case multiple segments died at once
14354 1169 }
14355 966396 }
14356
14357
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14358 {
14359 189 clk2=19;
14360 189 x=guys.spr(index+1)->x;
14361 189 y=guys.spr(index+1)->y;
14362 189 setmapflag(mTMPNORET);
14363 189 }
14364
14365 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14366 //which is... disastrous.
14367 233316 hp = 1;
14368 233316 return enemy::animate(index);
14369 236907 }
14370
14371 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14372 2267 {
14373
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14374 {
14375
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 x=64;
14376
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 y=80;
14377 2267 }
14378 2267 int32_t incr = 16;
14379 //Don't spawn in pits.
14380
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14381 {
14382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14383 {
14384 //move if we spawn over a pit
14385 //check each direction
14386
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14387 {
14388
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14389 }
14390
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14391 {
14392
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14393 }
14394
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14395 {
14396
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14397 }
14398
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14399 {
14400
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14401 }
14402
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14403 {
14404 y -= incr; break;
14405 }
14406
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14407 {
14408 y+=incr; break;
14409 }
14410
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14411 {
14412
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14413 }
14414
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14415 {
14416 x+=incr; y+=incr; break;
14417 }
14418 170 else continue;
14419
14420 }
14421
14422 525 }
14423
14424 2267 hxofs=1000;
14425 2267 hit_width=8;
14426 2267 mainguy=false;
14427 2267 count_enemy=(id<0x2000)?true:false;
14428
14429 //set up move history
14430
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14431
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14432
14433 2267 bgsfx = -1;
14434 2267 isCore = false;
14435
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14436 2267 }
14437
14438 985563 bool esLanmola::animate(int32_t index)
14439 {
14440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14441 // Shouldn't be possible, but who knows
14442
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14443 18 dying=true;
14444
14445
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14446 {
14447 19167 xofs=0;
14448
14449
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14450 9306 item_set=0;
14451
14452 19167 return Dead(index);
14453 }
14454
14455
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14456 {
14457 930450 hxofs=4;
14458
14459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14460 {
14461 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14462 930450 prevState.pop_front();
14463 930450 prevState.push_back(newstate);
14464 930450 x = newstate.first.first;
14465 930450 y = newstate.first.second;
14466 930450 dir = newstate.second;
14467 930450 }
14468 930450 }
14469
14470 966396 return enemy::animate(index);
14471 985563 }
14472
14473 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14474 {
14475
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14476 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14477
14478 590 return 0;
14479 2655 }
14480
14481 990931 void esLanmola::draw(BITMAP *dest)
14482 {
14483 990931 tile=o_tile;
14484 990931 int32_t fdiv = frate/4;
14485
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14486
14487
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14488 990931 efrate:((clk>=(frate>>1))?1:0);
14489
14490
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14491 {
14492
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14493 {
14494 481767 tile+=20;
14495
14496
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14497 {
14498 128742 tile+=20;
14499 128742 }
14500 481767 }
14501
14502
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14503 {
14504 case up:
14505 141419 flip=0;
14506 141419 break;
14507
14508 case down:
14509 140994 flip=0;
14510 140994 tile+=4;
14511 140994 break;
14512
14513 case left:
14514 159500 flip=0;
14515 159500 tile+=8;
14516 159500 break;
14517
14518 case right:
14519 187019 flip=0;
14520 187019 tile+=12;
14521 187019 break;
14522 }
14523
14524 628932 tile+=f2;
14525 628932 }
14526 else
14527 {
14528
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14529 {
14530 271456 tile+=1;
14531 271456 }
14532 }
14533
14534
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14535 953893 enemy::draw(dest);
14536 990931 }
14537
14538 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14539 150 {
14540 //these are here to bypass compiler warnings about unused arguments
14541 150 Clk=Clk;
14542 150 superman=1;
14543
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14544 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14545
14546
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14547 692 arm[i]=i;
14548
14549 150 fading=fade_blue_poof;
14550 //nets+4680;
14551 150 adjusted=false;
14552
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14553 150 }
14554
14555 66494 bool eManhandla::animate(int32_t index)
14556 {
14557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14558
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14559 1382 return Dead(index);
14560
14561
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14562 {
14563 2471 removearmos(x,y,ffcactivated);
14564 2471 }
14565
14566
14567 // check arm status, move dead ones to end of group
14568
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14569 {
14570 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14571
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14572 {
14573
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14574 {
14575 552 zc_swap(arm[j],arm[j+1]);
14576 552 guys.swap(index+j+1,index+j+2);
14577 552 }
14578
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14579 {
14580 87 leave_item();
14581 87 }
14582 424 --armcnt;
14583 424 --i;
14584 424 continue;
14585 }
14586
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14587 {
14588
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14589 {
14590 508 cur_arm->o_tile=o_tile+40;
14591 508 cur_arm->parent_script_UID = this->script_UID;
14592 508 }
14593 else
14594 {
14595 184 cur_arm->o_tile=o_tile+160;
14596 184 cur_arm->parent_script_UID = this->script_UID;
14597 }
14598 692 }
14599 193194 }
14600
14601 65112 adjusted=true;
14602
14603 // move or die
14604
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14605 83 hp=0;
14606 else
14607 {
14608 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14609
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14610
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14611 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14612
14613
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14614 {
14615
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14616 {
14617
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14618 {
14619 case 0:
14620 38579 dy1=-24;
14621 38579 break;
14622
14623 case 1:
14624 36328 dy2=31;
14625 36328 break;
14626
14627 case 2:
14628 36250 dx1=-16;
14629 36250 break;
14630
14631 case 3:
14632 39862 dx2=31;
14633 39862 break;
14634 }
14635 151019 }
14636 53584 }
14637 else
14638 {
14639 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14640
14641
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14642 {
14643
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14644 {
14645 case 0:
14646 12012 dy1=-32;
14647 12012 break;
14648
14649 case 1:
14650 7730 dy2=39;
14651 7730 break;
14652
14653 case 2:
14654 9837 dx1=-24;
14655 9837 break;
14656
14657 case 3:
14658 12596 dx2=39;
14659 12596 break;
14660 }
14661 42175 }
14662 }
14663
14664 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14665
14666
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14667 {
14668 193194 zfix dx=(zfix)0,dy=(zfix)0;
14669
14670
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14671 {
14672
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14673 {
14674 case 0:
14675 38579 dy=-16;
14676 38579 break;
14677
14678 case 1:
14679 36328 dy=16;
14680 36328 break;
14681
14682 case 2:
14683 36250 dx=-16;
14684 36250 break;
14685
14686 case 3:
14687 39862 dx=16;
14688 39862 break;
14689 }
14690 151019 }
14691 else
14692 {
14693
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14694 {
14695 case 0:
14696 5447 dy=-24;
14697 5447 dx=-8;
14698 5447 break;
14699
14700 case 1:
14701 3986 dy=24;
14702 3986 dx=8;
14703 3986 break;
14704
14705 case 2:
14706 4163 dx=-24;
14707 4163 dy=8;
14708 4163 break;
14709
14710 case 3:
14711 6774 dx=24;
14712 6774 dy=-8;
14713 6774 break;
14714
14715 case 4:
14716 6565 dy=-24;
14717 6565 dx=8;
14718 6565 break;
14719
14720 case 5:
14721 3744 dy=24;
14722 3744 dx=-8;
14723 3744 break;
14724
14725 case 6:
14726 5674 dx=-24;
14727 5674 dy=-8;
14728 5674 break;
14729
14730 case 7:
14731 5822 dx=24;
14732 5822 dy=8;
14733 5822 break;
14734 }
14735 }
14736
14737 193194 guys.spr(index+i+1)->x = x+dx;
14738 193194 guys.spr(index+i+1)->y = y+dy;
14739 193194 }
14740 }
14741
14742 65112 return enemy::animate(index);
14743 66494 }
14744
14745
14746 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14747 {
14748 1751 int32_t wpnId = w->id;
14749
14750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14751 return 0;
14752
14753
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14754 {
14755 case wBomb:
14756 case wSBomb:
14757 case wSword:
14758 case wHammer:
14759 case wWand:
14760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14761
14762 case wLitBomb:
14763 case wLitSBomb:
14764 case wBait:
14765 case wWhistle:
14766 case wFire:
14767 case wWind:
14768 case wSSparkle:
14769 case wFSparkle:
14770 case wPhantom:
14771 1709 return 0;
14772
14773 case wHookshot:
14774 case wBrang:
14775 sfx(WAV_CHINK,pan(int32_t(x)));
14776 break;
14777
14778 default:
14779
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14780 else sfx(WAV_CHINK,pan(int32_t(x)));
14781
14782 42 }
14783
14784 42 return 1;
14785 1751 }
14786
14787 66490 void eManhandla::draw(BITMAP *dest)
14788 {
14789 66490 tile=o_tile;
14790 66490 int32_t fdiv = frate/4;
14791
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14792
14793
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14794 66490 efrate:((clk>=(frate>>1))?1:0);
14795
14796
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14797 {
14798
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14799 {
14800
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14801 {
14802 case up: //u
14803 4771 flip=0;
14804 4771 break;
14805
14806 case l_up: //d
14807 4640 flip=0;
14808 4640 tile+=4;
14809 4640 break;
14810
14811 case l_down: //l
14812 4995 flip=0;
14813 4995 tile+=8;
14814 4995 break;
14815
14816 case left: //r
14817 5574 flip=0;
14818 5574 tile+=12;
14819 5574 break;
14820
14821 case r_down: //ul
14822 3793 flip=0;
14823 3793 tile+=20;
14824 3793 break;
14825
14826 case down: //ur
14827 3930 flip=0;
14828 3930 tile+=24;
14829 3930 break;
14830
14831 case r_up: //dl
14832 3908 flip=0;
14833 3908 tile+=28;
14834 3908 break;
14835
14836 case right: //dr
14837 5883 flip=0;
14838 5883 tile+=32;
14839 5883 break;
14840 }
14841
14842 37494 tile+=f2;
14843 37494 enemy::draw(dest);
14844 37494 } //manhandla 2, big body
14845 else
14846 {
14847
14848
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14849 {
14850 case up: //u
14851 1277 flip=0;
14852 1277 break;
14853
14854 case l_up: //d
14855 1360 flip=0;
14856 1360 tile+=8;
14857 1360 break;
14858
14859 case l_down: //l
14860 2242 flip=0;
14861 2242 tile+=40;
14862 2242 break;
14863
14864 case left: //r
14865 1789 flip=0;
14866 1789 tile+=48;
14867 1789 break;
14868
14869 case r_down: //ul
14870 1345 flip=0;
14871 1345 tile+=80;
14872 1345 break;
14873
14874 case down: //ur
14875 805 flip=0;
14876 805 tile+=88;
14877 805 break;
14878
14879 case r_up: //dl
14880 948 flip=0;
14881 948 tile+=120;
14882 948 break;
14883
14884 case right: //dr
14885 1542 flip=0;
14886 1542 tile+=128;
14887 1542 break;
14888 }
14889
14890 11308 tile+=(f2*2);
14891 11308 xofs-=8;
14892 11308 yofs-=8;
14893 11308 drawblock(dest,15);
14894 11308 xofs+=8;
14895 11308 yofs+=8;
14896 }
14897 48802 }
14898 else
14899 {
14900
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14901 {
14902 17173 enemy::draw(dest);
14903 17173 }
14904 else
14905 {
14906 515 xofs-=8;
14907 515 yofs-=8;
14908 515 enemy::draw(dest);
14909 515 xofs+=16;
14910 515 enemy::draw(dest);
14911 515 yofs+=16;
14912 515 enemy::draw(dest);
14913 515 xofs-=16;
14914 515 enemy::draw(dest);
14915 515 xofs+=8;
14916 515 yofs-=8;
14917 }
14918 }
14919 66490 }
14920
14921 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14922 692 {
14923 692 id=misc=clk;
14924 692 dir = clk & 3;
14925 692 clk=0;
14926 692 mainguy=count_enemy=false;
14927 692 dummy_bool[0]=false;
14928 692 item_set=0;
14929 692 bgsfx=-1;
14930 692 deadsfx = WAV_EDEAD;
14931
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14932 692 isCore = false;
14933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14934 692 }
14935
14936 200202 bool esManhandla::animate(int32_t index)
14937 {
14938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14939
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14940 7008 return Dead(index);
14941
14942
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14943 {
14944 12404 removearmos(x,y,ffcactivated);
14945 12404 }
14946
14947
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14948 {
14949 27896 clk2=unsigned(zc_oldrand())%5+5;
14950 27896 clk3^=1;
14951 27896 }
14952
14953
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14954 {
14955 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14956 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14957 1491 }
14958
14959 193194 return enemy::animate(index);
14960 200202 }
14961
14962 200186 void esManhandla::draw(BITMAP *dest)
14963 {
14964 200186 tile=o_tile;
14965 200186 int32_t fdiv = frate/4;
14966
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14967
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14968 200186 efrate:((clk>=(frate>>1))?1:0);
14969
14970
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14971 {
14972
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14973 {
14974 case up:
14975 39945 break;
14976
14977 case down:
14978 36845 tile+=4;
14979 36845 break;
14980
14981 case left:
14982 39966 tile+=8;
14983 39966 break;
14984
14985 case right:
14986 41960 tile+=12;
14987 41960 break;
14988 }
14989
14990 158716 tile+=f2;
14991 158716 }
14992 else
14993 {
14994
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14995 {
14996 case down:
14997 8961 flip=2;
14998
14999 [[fallthrough]];
15000 case up:
15001 21355 tile=(clk3)?188:189;
15002 21355 break;
15003
15004 case right:
15005 12232 flip=1;
15006 [[fallthrough]];
15007
15008 case left:
15009 20115 tile=(clk3)?186:187;
15010 20115 break;
15011 }
15012 }
15013
15014 200186 enemy::draw(dest);
15015 200186 }
15016
15017 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15018 168 {
15019
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
15020 {
15021
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 x = 120;
15022
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 y = 48;
15023 168 }
15024 else
15025 {
15026 if ( !(editorflags & ENEMY_FLAG6) )
15027 {
15028 x = X; y = Y;
15029 }
15030 else
15031 {
15032 x = X+8; y = Y;
15033 }
15034 }
15035 168 hzsz = 32; // can't be jumped.
15036 168 flameclk=0;
15037 168 misc=clk; // total head count
15038 168 clk3=clk; // live head count
15039 168 clk=0;
15040 168 clk2=60; // fire ball clock
15041 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15042
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15043 168 dir = down;
15044 168 hxofs=4;
15045 168 hit_width=8;
15046 // frate=17*4;
15047 168 fading=fade_blue_poof;
15048 //nets+5420;
15049
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
15050 {
15051 /*
15052 necktile=o_tile+8;
15053 if (dmisc3)
15054 {
15055 necktile+=8;
15056 }
15057 */
15058 133 necktile=o_tile+dmisc6;
15059 133 }
15060 else
15061 {
15062 35 necktile=s_tile;
15063 }
15064 168 }
15065
15066 155290 bool eGleeok::animate(int32_t index)
15067 {
15068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
15069
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
15070 2199 return Dead(index);
15071
15072
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
15073 {
15074 684 removearmos(x,y,ffcactivated);
15075 684 }
15076
15077 // Check if a head was killed somehow...
15078
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
15079 51372 clk3=guys.Count()-index-1;
15080
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
15081 87041 misc=guys.Count()-index-1;
15082
15083 //fix for the "kill all enemies" item
15084
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
15085 {
15086
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15087 {
15088 // I haven't seen this fail, but it seems like it ought to be
15089 // possible, so I'm checking for it. - Saf
15090
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15091 break;
15092 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15093 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15094 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15095 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15096 12 }
15097
15098 6 clk3=0;
15099
15100
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15101 {
15102
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15103 break;
15104 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15105 12 }
15106 6 }
15107
15108
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
15109 {
15110 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
15111 403171 head->dummy_int[1]=necktile;
15112 403171 head->parent_script_UID = this->script_UID;
15113
15114
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
15115 {
15116 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15117 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15118 320127 }
15119 else
15120 {
15121 83044 head->dummy_int[2]=necktile+1; //connected head tile
15122 83044 head->dummy_int[3]=necktile+2; //flying head tile
15123 }
15124
15125 403171 head->dmisc5=dmisc5; //neck segments
15126
15127 /*
15128 if (dmisc3)
15129 {
15130 head->dummy_bool[0]=true;
15131 }
15132 */
15133
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
15134 {
15135
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
15136 {
15137 1228 hp -= 1000 - head->hp;
15138 1228 hclk = 33;
15139
15140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15141
15142 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
15143 1228 }
15144
15145 5655 head->hclk = 0;
15146 5655 }
15147
15148 // Must be set in case of naughty ZScripts
15149 403171 head->hp = 1000;
15150 403171 }
15151
15152
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
15153 {
15154 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15155 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
15156 415 }
15157
15158
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
15159 {
15160
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
15161 {
15162 1287 int32_t i=zc_oldrand()%misc;
15163 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
15164 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15165 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
15166 1287 clk2=0;
15167 1287 }
15168 95682 }
15169 else
15170 {
15171
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
15172 {
15173 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15174 557 head->timer=zc_oldrand()%50+50;
15175 557 clk2=0;
15176 557 }
15177 }
15178
15179
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
15180 {
15181
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
15182 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15183
15184
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(index);
15185 127 }
15186
15187 153091 return enemy::animate(index);
15188 155290 }
15189
15190 1239 int32_t eGleeok::takehit(weapon*,weapon*)
15191 {
15192 1239 return 0;
15193 }
15194
15195 156918 void eGleeok::draw(BITMAP *dest)
15196 {
15197 156918 tile=o_tile;
15198
15199
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
15200 {
15201 2199 enemy::draw(dest);
15202 2199 return;
15203 }
15204
15205 154719 int32_t f=clk/17;
15206
15207
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
15208 {
15209 // body
15210 120524 xofs=-8;
15211 120524 yofs=32;
15212
15213
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
15214
15215 {
15216 case 0:
15217 9155 tile+=0;
15218 9155 break;
15219
15220 case 1:
15221 10095 tile+=2;
15222 10095 break;
15223
15224 case 2:
15225 8686 tile+=4;
15226 8686 break;
15227
15228 default:
15229 92588 tile+=6;
15230 92588 break;
15231 }
15232 120524 }
15233 else
15234 {
15235 // body
15236 34195 xofs=-8;
15237 34195 yofs=32;
15238
15239
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
15240 {
15241 case 0:
15242 2514 tile+=0;
15243 2514 break;
15244
15245 case 2:
15246 2459 tile+=4;
15247 2459 break;
15248
15249 default:
15250 29222 tile+=2;
15251 29222 break;
15252 }
15253 }
15254
15255 154719 enemy::drawblock(dest,15);
15256 156918 }
15257
15258 156918 void eGleeok::draw2(BITMAP *dest)
15259 {
15260 // the neck stub
15261 156918 tile=necktile;
15262 156918 xofs=0;
15263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15264
15265
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
15266 {
15267 122181 tile+=((clk&24)>>3);
15268 122181 }
15269
15270
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15271 {
15272
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15273 737 sprite::drawcloaked(dest);
15274 else
15275 153982 sprite::draw(dest);
15276 154719 }
15277 156918 }
15278
15279
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15280 533 {
15281
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15282
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15283 // dummy_bool[0]=false;
15284 533 timer=0;
15285 /* fixing */
15286 533 hp=1000;
15287
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15288 533 item_set=0;
15289 //x=120; y=70;
15290
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15291
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15292 533 hxofs=4;
15293 533 hit_width=8;
15294
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15295 533 clk2=clk; // how int32_t to wait before moving first time
15296 533 clk=0;
15297 533 mainguy=count_enemy=false;
15298
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15299 533 clk3=((dir&2)>>1)+2; // left or right
15300 533 dir&=1; // up or down
15301
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15302 533 isCore = false;
15303
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15304
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15305 {
15306 2132 nxoffset[i] = 0;
15307 2132 nyoffset[i] = 0;
15308
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15309
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15310 2132 }
15311
15312 533 necktile=0;
15313 //TODO compatibility? -DD
15314 /*
15315 for(int32_t i=0; i<4; i++)
15316 {
15317 nx[i]=124;
15318 ny[i]=i*6+48;
15319 }*/
15320 533 bgsfx=-1;
15321 //no need for deadsfx
15322 533 }
15323
15324 515535 bool esGleeok::animate(int32_t index)
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15327 // don't call removearmos() - it's a segment.
15328
15329 515535 dmisc5=vbound(dmisc5,1,255);
15330
15331
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15332 {
15333 402762 x = (xoffset+parent->x);
15334 402762 y = (yoffset+parent->y);
15335
15336
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15337 {
15338 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15339 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15340 1611048 }
15341 402762 }
15342
15343 // set up the head tiles
15344 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15345 /*
15346 if (dummy_bool[0]) //if this is a flame gleeok
15347 {
15348 headtile+=180;
15349 }
15350 */
15351 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15352 515535 flyingheadtile=dummy_int[3];
15353
15354 // set up the neck tiles
15355 515535 necktile=dummy_int[1];
15356
15357
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15358 {
15359 402833 necktile+=((clk&24)>>3);
15360 402833 }
15361
15362 /*
15363 else
15364 {
15365 necktile=145;
15366 }
15367 */
15368 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15369
15370
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15371 {
15372 case 0: // live head
15373 // set up the attached head tiles
15374 402762 tile=headtile;
15375
15376
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15377 {
15378 319820 tile+=((clk&24)>>3);
15379 /*
15380 if (dummy_bool[0]) {
15381 tile+=1561;
15382 }
15383 */
15384 319820 }
15385
15386 /*
15387 else
15388 {
15389 tile=146;
15390 }
15391 */
15392
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15393 {
15394
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15395
15396
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15397
15398
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15399 {
15400 292 dir^=1;
15401 292 }
15402
15403 92832 zfix tempx = x;
15404 92832 zfix tempy = y;
15405
15406 92832 sprite::move(step);
15407 92832 xoffset += (x-tempx);
15408 92832 yoffset += (y-tempy);
15409
15410
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15411 {
15412 3863 clk3^=1;
15413 3863 clk2=-4;
15414 3863 }
15415 else
15416 {
15417
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15418 {
15419 978 clk3=right;
15420 978 }
15421
15422
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15423 {
15424 961 clk3=left;
15425 961 }
15426
15427
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15428 {
15429 3713 clk3^=1; // x jig
15430 3713 }
15431 else
15432 {
15433
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15434 {
15435 851 clk3^=1; // x switch back
15436 851 }
15437
15438 85256 clk2=-4;
15439 }
15440 }
15441
15442 92832 zc_swap(dir,clk3);
15443 92832 tempx = x;
15444 92832 tempy = y;
15445 92832 sprite::move(step);
15446 92832 xoffset += (x-tempx);
15447 92832 yoffset += (y-tempy);
15448 92832 zc_swap(dir,clk3);
15449
15450
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15451 {
15452 278496 nxoffset[i] = (zc_oldrand()%3);
15453 278496 nyoffset[i] = (zc_oldrand()%3);
15454 278496 }
15455 92832 }
15456
15457 402762 break;
15458
15459 case 1: // flying head
15460
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15461
15462 {
15463 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15464 105482 }
15465
15466 112071 break;
15467
15468 // the following are messages sent from the main guy...
15469 case -1: // got chopped off
15470 {
15471 300 misc=1;
15472 300 superman=1;
15473 300 hxofs=xofs=0;
15474 300 hit_width=16;
15475 300 cs=8;
15476 300 clk=-24;
15477 300 clk2=40;
15478 300 dir=(zc_oldrand()&7)+8;
15479 300 step=8.0/9.0;
15480 }
15481 300 break;
15482
15483 case -2: // the big guy is dead
15484 402 return true;
15485 }
15486
15487
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15488 {
15489
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15490 {
15491 4791 FireBreath(true);
15492 4791 }
15493
15494 40125 --timer;
15495 40125 }
15496
15497 515133 return enemy::animate(index);
15498 515535 }
15499
15500 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15501 {
15502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15503 {
15504 int32_t wpnId = w->id;
15505
15506 if(dying)
15507 return 0;
15508
15509 switch(wpnId)
15510 {
15511 case wLitBomb:
15512 case wLitSBomb:
15513 case wBait:
15514 case wWhistle:
15515 case wFire:
15516 case wWind:
15517 case wSSparkle:
15518 case wFSparkle:
15519 case wPhantom:
15520 return 0;
15521
15522 case wHookshot:
15523 case wBrang:
15524 case wBeam:
15525 case wArrow:
15526 case wMagic:
15527 case wBomb:
15528 case wSBomb:
15529 sfx(WAV_CHINK,pan(int32_t(x)));
15530 break;
15531 default:
15532 break;
15533 }
15534
15535 return 1;
15536 }
15537 else
15538 {
15539 7080 int32_t ret = enemy::takehit(w,realweap);
15540
15541
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15542 5655 return 2; // force it to wait a frame before checking sword attacks again
15543
15544 1425 return ret;
15545 }
15546 7080 }
15547
15548 521456 void esGleeok::draw(BITMAP *dest)
15549 {
15550 521456 dmisc5=vbound(dmisc5,1,255);
15551
15552
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15553 {
15554 case 0: //neck
15555
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15556 {
15557
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15558 {
15559
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15560 {
15561
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15562 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
15563 else
15564 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
15565 978198 }
15566 else
15567 {
15568
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15569 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
15570 else
15571 249120 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
15572 }
15573 1227318 }
15574 409106 }
15575
15576 409106 break;
15577
15578 case 1: //flying head
15579 112350 tile=flyingheadtile;
15580
15581
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15582 {
15583 82692 tile+=((clk&24)>>3);
15584 82692 break;
15585 }
15586
15587 /*
15588 else
15589 {
15590 tile=(clk&1)?147:148;
15591 break;
15592 }
15593 */
15594 29658 }
15595 521456 }
15596
15597 521456 void esGleeok::draw2(BITMAP *dest)
15598 {
15599 521456 enemy::draw(dest);
15600 521456 }
15601
15602 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15603 190 {
15604
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15605 {
15606
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15607
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15608 190 }
15609 else { x = X; y = Y; }
15610 190 adjusted=false;
15611
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15612 //step=0.25;
15613 190 flycnt=dmisc1;
15614 190 flycnt2=dmisc2;
15615 190 loopcnt=0;
15616 190 clk4 = 0;
15617 190 clk5 = 0;
15618 190 clk6 = 0;
15619 190 clk7 = 0;
15620
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15622 {
15623
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15624 {
15625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15626 105 else dmisc29 = (84 / 3);
15627 105 }
15628 else
15629 {
15630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15631 85 else dmisc29 = (84 / 2);
15632 }
15633 190 }
15634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15635 {
15636
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15637 {
15638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15639 105 else dmisc30 = (84 / 3)*0.5;
15640 105 }
15641 else
15642 {
15643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15644 85 else dmisc30 = (84 / 2)*0.5;
15645 }
15646 190 }
15647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15648 {
15649
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15650 {
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15652 105 else dmisc31 = (84 / 3)*2;
15653 105 }
15654 else
15655 {
15656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15657 85 else dmisc31 = (84 / 2)*0.5;
15658 }
15659 190 }
15660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15661 {
15662
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15663 {
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15665 105 else dmisc32 = (84 / 3);
15666 105 }
15667 else
15668 {
15669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15670 85 else dmisc32 = (84 / 2)*0.25;
15671 }
15672 190 }
15673
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15674 190 }
15675
15676 161885 bool ePatra::animate(int32_t index)
15677 {
15678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15679
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15680 {
15681
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15682 {
15683 72 ((enemy*)guys.spr(i))->hp = -1000;
15684 72 }
15685
15686 1444 return Dead(index);
15687 }
15688
15689 160441 double basesize = 84;
15690
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15691 160441 double halfsize = basesize / 2;
15692 160441 double quartersize = halfsize / 2;
15693 160441 double twothirdsize = (basesize / 3)*2;
15694 160441 double onethirdsize = (basesize / 3);
15695
15696
15697
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15698 {
15699 36934 removearmos(x,y,ffcactivated);
15700 36934 }
15701
15702
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15703 {
15704
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15705
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15706
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15707 {
15708 1797 clk2=0;
15709
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15710 {
15711
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15712 932 --loopcnt;
15713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15714 {
15715
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
15716 {
15717
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15718 356 else loopcnt=dmisc7;
15719 356 }
15720 865 }
15721 else if (loopcnt == -1) loopcnt=dmisc7;
15722 else ++loopcnt;
15723
15724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15725 1797 }
15726 else
15727 {
15728 loopcnt = 0;
15729 misc = 1;
15730 }
15731 1797 }
15732 160441 }
15733
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15734
15735
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15736 {
15737 if (dmisc5 == 1 || dmisc5 == 3)
15738 {
15739 if (get_qr(qr_NEWENEMYTILES))
15740 {
15741 if (clk7 <= 0 || clk6 != -16) ++clk6;
15742 if (clk6 == 0) o_tile=d->e_tile;
15743 else
15744 {
15745 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15746 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15747 }
15748 }
15749 else clk6 = 0;
15750 }
15751 }
15752
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15753
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15754
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15755
15756
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15757
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15758
15759
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15760 {
15761 //outside ring
15762
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15763 {
15764
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15765 {
15766 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15767 1152 enemy *s = ((enemy*)guys.spr(i));
15768 1152 s->parent_script_UID = this->script_UID;
15769 1152 }
15770 else
15771 {
15772 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15773 192 enemy *s = ((enemy*)guys.spr(i));
15774 192 s->parent_script_UID = this->script_UID;
15775 }
15776
15777 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15778 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15779 1344 }
15780
15781
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15782 {
15783
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15784 {
15785 2889 guys.swap(j,j+1);
15786 2889 }
15787
15788
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15789 764 }
15790 else
15791 {
15792 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15793
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15794
15795
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15796 {
15797 //maybe playing_field_offset here?
15798
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15799 {
15800
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15801
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15802 237330 }
15803 else
15804 {
15805 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15806 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15807 }
15808
15809 447583 temp_x=guys.spr(i)->x;
15810 447583 temp_y=guys.spr(i)->y;
15811 447583 }
15812 else //Oval
15813 {
15814 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15815 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15816
15817
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15818 {
15819 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15820
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15821 121041 }
15822 else
15823 {
15824 90996 guys.spr(i)->x = circle_x;
15825 90996 guys.spr(i)->y = circle_y;
15826 }
15827
15828 212037 temp_x=circle_x;
15829 212037 temp_y=circle_y;
15830 }
15831
15832 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15833 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15834
15835
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15836 {
15837 83117 guys.spr(i)->dir=l_down;
15838 83117 }
15839
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15840 {
15841 83568 guys.spr(i)->dir=left;
15842 83568 }
15843
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15844 {
15845 82454 guys.spr(i)->dir=l_up;
15846 82454 }
15847
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15848 {
15849 82188 guys.spr(i)->dir=up;
15850 82188 }
15851
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15852 {
15853 81600 guys.spr(i)->dir=r_up;
15854 81600 }
15855
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15856 {
15857 81993 guys.spr(i)->dir=right;
15858 81993 }
15859
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15860 {
15861 81699 guys.spr(i)->dir=r_down;
15862 81699 }
15863 else
15864 {
15865 83001 guys.spr(i)->dir=down;
15866 }
15867
15868 659620 guys.spr(i)->x += x;
15869 659620 guys.spr(i)->y += y;
15870 }
15871 660384 }
15872
15873
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15874 {
15875 32331 int timeneeded = 48;
15876 32331 int patbreath = (zc_oldrand()%50+50);
15877
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15878
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15879 {
15880 timeneeded = 48 + patbreath;
15881 }
15882
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15883 {
15884 timeneeded = 48 + 96;
15885 }
15886
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15887
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15888
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15889 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15890 249 && (clk6 >= 0) //if not in the middle of firing...
15891 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15892
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15893 {
15894
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15895 {
15896 case patratSTREAM:
15897 {
15898 clk7 = 97;
15899 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15900 else clk6 = 0;
15901 break;
15902 }
15903 case patratBREATH:
15904 {
15905 clk7 = patbreath;
15906 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15907 else clk6 = 0;
15908 break;
15909 }
15910 default:
15911 {
15912
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15913 {
15914 clk6 = -48;
15915 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15916 }
15917 else
15918 {
15919 249 clk6 = 0;
15920
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15921 249 FirePatraWeapon();
15922 }
15923 249 break;
15924 }
15925 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15926 249 }
15927
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15928 {
15929 switch(dmisc28)
15930 {
15931 case patratSTREAM:
15932 {
15933 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15934 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15935 break;
15936 }
15937 case patratBREATH:
15938 {
15939 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15940 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15941 break;
15942 }
15943 default:
15944 {
15945 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15946 {
15947 FirePatraWeapon();
15948 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15949 }
15950 break;
15951 }
15952 }
15953 }
15954 32331 }
15955
15956 160441 int randattempts = 0;
15957 160441 int randeye = 0;
15958
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15959 {
15960 46240 do
15961 {
15962
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15963 46240 randeye += (index + flycnt + 1);
15964 46240 ++randattempts;
15965
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15966 46240 }
15967 160441 bool dofire = false;
15968
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15969 {
15970 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15971 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15972 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15973 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15974 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15975 {
15976 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15977 {
15978 if (clk5 >= dmisc19)
15979 {
15980 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15981 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15982 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
15983 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
15984 || dmisc18 == -1)
15985 dofire = true;
15986 }
15987 }
15988 }
15989 }
15990
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15991 {
15992
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15993 {
15994
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15995 {
15996 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15997
15998
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15999 {
16000
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16001 {
16002
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
16003 {
16004 // Center eye shoots projectiles; make room for its firing tiles
16005 case 1:
16006 case 3:
16007 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16008 144 break;
16009
16010 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16011 default:
16012 case 2:
16013 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16014 168 break;
16015 }
16016 312 }
16017 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16018 312 }
16019 else
16020 {
16021 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16022 }
16023
16024 312 ((enemy*)guys.spr(i))->cs=dmisc9;
16025
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16026 312 }
16027
16028
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
16029 {
16030 263816 ((enemy*)guys.spr(i))->superman=true;
16031 263816 }
16032 else
16033 {
16034 70613 ((enemy*)guys.spr(i))->superman=false;
16035 }
16036
16037
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
16038 {
16039
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16040 {
16041 269 guys.swap(j,j+1);
16042 269 }
16043
16044
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16045 145 }
16046 else
16047 {
16048 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16049
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16050
16051
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
16052 {
16053
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
16054 {
16055
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16056
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16057 168378 }
16058 else
16059 {
16060 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16061 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16062 }
16063
16064 327025 temp_x=guys.spr(i)->x;
16065 327025 temp_y=guys.spr(i)->y;
16066 327025 }
16067 else
16068 {
16069 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16070 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16071
16072
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16073 {
16074 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16075
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16076 3965 }
16077 else
16078 {
16079 3294 guys.spr(i)->x = circle_x;
16080 3294 guys.spr(i)->y = circle_y;
16081 }
16082
16083 7259 temp_x=circle_x;
16084 7259 temp_y=circle_y;
16085 }
16086
16087 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16088 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16089
16090
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16091 {
16092 41746 guys.spr(i)->dir=l_down;
16093 41746 }
16094
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16095 {
16096 41734 guys.spr(i)->dir=left;
16097 41734 }
16098
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16099 {
16100 41742 guys.spr(i)->dir=l_up;
16101 41742 }
16102
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16103 {
16104 41758 guys.spr(i)->dir=up;
16105 41758 }
16106
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16107 {
16108 41830 guys.spr(i)->dir=r_up;
16109 41830 }
16110
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16111 {
16112 41824 guys.spr(i)->dir=right;
16113 41824 }
16114
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16115 {
16116 41852 guys.spr(i)->dir=r_down;
16117 41852 }
16118 else
16119 {
16120 41798 guys.spr(i)->dir=down;
16121 }
16122
16123 334284 guys.spr(i)->x += x;
16124 334284 guys.spr(i)->y = y-guys.spr(i)->y;
16125
16126
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16127 {
16128 /*
16129 if(!(zc_oldrand()&127))
16130 {
16131 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16132 sfx(wpnsfx(wpn),pan(int32_t(x)));
16133 }
16134 */
16135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16136 {
16137 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16138 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16139 {
16140 if (dmisc5 == 3)
16141 {
16142 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16143 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16144 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16145 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16146 }
16147 else
16148 {
16149 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16150 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16151 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16152 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16153 }
16154 }
16155 else
16156 {
16157 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16158 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16159 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16160 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16161 }
16162 }
16163
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16164
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16165
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16166 {
16167
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
16168 {
16169 case 4: //Single one rapidfires
16170 {
16171 if (dofire && i == randeye)
16172 {
16173 ((esPatra*)guys.spr(i))->clk5 = -16;
16174 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16175 ((esPatra*)guys.spr(i))->clk4 = 96;
16176 clk5 = -3;
16177 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16178 }
16179 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16180 {
16181 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16182 sfx(wpnsfx(wpn),pan(int32_t(x)));
16183 }
16184 break;
16185 }
16186 case 3: //Ring
16187 {
16188 if (dofire)
16189 {
16190 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16191 {
16192 ((esPatra*)guys.spr(i))->clk5 = -48;
16193 clk5 = -48;
16194 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16195 }
16196 else
16197 {
16198 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16199 sfx(wpnsfx(wpn),pan(int32_t(x)));
16200 int32_t m=Ewpns.Count()-1;
16201 weapon *ew = (weapon*)(Ewpns.spr(m));
16202
16203 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16204 ((esPatra*)guys.spr(i))->clk5 = 0;
16205 clk5 = 0;
16206 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16207 }
16208 }
16209 if (((esPatra*)guys.spr(i))->clk5 == -16)
16210 {
16211 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16212 sfx(wpnsfx(wpn),pan(int32_t(x)));
16213 int32_t m=Ewpns.Count()-1;
16214 weapon *ew = (weapon*)(Ewpns.spr(m));
16215
16216 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16217 }
16218 break;
16219 }
16220 case 2: //one after another
16221 {
16222 if (dofire)
16223 {
16224 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16225 clk5 = -48 - (12*flycnt2);
16226 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16227 }
16228 if (((esPatra*)guys.spr(i))->clk5 == -16)
16229 {
16230 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16231 sfx(wpnsfx(wpn),pan(int32_t(x)));
16232 }
16233 break;
16234 }
16235 case 1: //random one eye
16236 {
16237 if (dofire && i == randeye)
16238 {
16239 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16240 {
16241 ((esPatra*)guys.spr(i))->clk5 = -48;
16242 clk5 = -48;
16243 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16244 }
16245 else
16246 {
16247 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16248 sfx(wpnsfx(wpn),pan(int32_t(x)));
16249 ((esPatra*)guys.spr(i))->clk5 = 0;
16250 clk5 = 0;
16251 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16252 }
16253 }
16254 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16255 {
16256 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16257 sfx(wpnsfx(wpn),pan(int32_t(x)));
16258 }
16259 break;
16260 }
16261 default: //old behavior, all eyes can fire any time
16262 {
16263
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16264
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16265
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16266 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16267 {
16268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16269 {
16270 ((esPatra*)guys.spr(i))->clk5 = -48;
16271 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16272 }
16273 else
16274 {
16275 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16276 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
16277 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16278
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16279 }
16280 1155 }
16281
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16282 {
16283 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16284 sfx(wpnsfx(wpn),pan(int32_t(x)));
16285 }
16286 145268 break;
16287 }
16288 }
16289 145268 }
16290 145268 }
16291
16292 }
16293 334429 }
16294 46240 }
16295
16296 160441 adjusted=true;
16297 160441 return enemy::animate(index);
16298 161885 }
16299
16300 249 void ePatra::FirePatraWeapon()
16301 { //.707
16302 249 int32_t xoff = 0;
16303 249 int32_t yoff = 0;
16304
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16305 {
16306 xoff += (hit_width/2)-8;
16307 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16308 }
16309
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16310 {
16311 yoff += (hit_height/2)-8;
16312 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16313 }
16314 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16315
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16316 {
16317 case patrat8SHOT: //Fire Wizzrobe
16318 case patrat4SHOTDIAG:
16319 case patrat4SHOTRAND:
16320 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16321 {
16322 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16324 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16325 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16326
16327 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16328 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16329 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16330 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16331
16332 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16333 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16334 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16335 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16336
16337 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16338 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16339 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16340 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16341
16342 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16343 }
16344
16345 [[fallthrough]];
16346 case patrat4SHOTCARD: //Stalfos 3
16347 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16348 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16349 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16350 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16351 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16352 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16353 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16354 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16356 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16357 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16358 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16359 break;
16360
16361 default:
16362 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16363
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16364 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16365
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16366
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16367 {
16368 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16369 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16370 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16371 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16372 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16373 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16374 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16375 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16376 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16377 {
16378 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16379 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16380 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16381 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16382 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16383 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16384 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16385 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16386 }
16387 }
16388 249 break;
16389
16390 }
16391 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16392 //+0.46364761
16393 //11.80
16394 249 }
16395
16396 324242 void ePatra::draw(BITMAP *dest)
16397 {
16398 324242 tile=o_tile;
16399 324242 update_enemy_frame();
16400 324242 enemy::draw(dest);
16401 324242 }
16402
16403 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16404 {
16405 int32_t ret = enemy::defend(wpnId, power, edef);
16406
16407 if(ret < 0 && (flycnt||flycnt2))
16408 return 0;
16409
16410 return ret;
16411 }
16412
16413 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16414 {
16415 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16416
16417
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16418 1281 return 0;
16419
16420 452 return ret;
16421 1733 }
16422
16423 190 void ePatra::init_size_flags() {
16424 190 SIZEflags = d->SIZEflags;
16425
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16426
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16427 // al_trace("Enemy txsz:%i\n", txsz);
16428
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16429
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16431
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16435
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16436
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16437 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16439
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
16441 {
16442 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16443 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16444 }
16445
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16446
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16447
16448
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16449
16450 190 }
16451
16452 3312 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16453 1656 {
16454 //cs=8;
16455 1656 item_set=0;
16456 1656 misc=clk;
16457 1656 clk4 = 0;
16458 1656 clk5 = 0;
16459 1656 clk = -((misc*21)>>1)-1;
16460
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16461 1656 hit_width=12;
16462 1656 hit_height=12;
16463 1656 hxofs=2;
16464 1656 hyofs=2;
16465 1656 extend = 0;
16466 1656 txsz = 1;
16467 1656 tysz = 1;
16468 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16469 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16470 int32_t prntSIZEflags = prntenemy->SIZEflags;
16471 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16472 // al_trace("Enemy txsz:%i\n", txsz);
16473 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16474 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16475 else
16476 hxsz=12;
16477 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16478 else
16479 hysz=12;
16480 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16481 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16482 else
16483 hxofs=2;
16484 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16485 else hyofs=2;
16486 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16487 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16488 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16489 {
16490 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16491 }
16492
16493 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16494 */
16495 1656 mainguy=count_enemy=false;
16496 1656 bgsfx=-1;
16497 //o_tile=0;
16498
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16499 1656 deadsfx = WAV_EDEAD;
16500 1656 hitsfx = WAV_EHIT;
16501 1656 isCore = false;
16502 1656 }
16503
16504 1010584 bool esPatra::animate(int32_t index)
16505 {
16506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16507
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16508 15160 return Dead(index);
16509
16510 995424 return enemy::animate(index);
16511 1010584 }
16512
16513 2028196 void esPatra::draw(BITMAP *dest)
16514 {
16515
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16516 {
16517 1721294 tile = o_tile+(clk&3);
16518
16519
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16520 {
16521 case up: //u
16522 214278 flip=0;
16523 214278 break;
16524
16525 case down: //d
16526 217924 flip=0;
16527 217924 tile+=4;
16528 217924 break;
16529
16530 case left: //l
16531 215346 flip=0;
16532 215346 tile+=8;
16533 215346 break;
16534
16535 case right: //r
16536 215726 flip=0;
16537 215726 tile+=12;
16538 215726 break;
16539
16540 case l_up: //ul
16541 213062 flip=0;
16542 213062 tile+=20;
16543 213062 break;
16544
16545 case r_up: //ur
16546 214350 flip=0;
16547 214350 tile+=24;
16548 214350 break;
16549
16550 case l_down: //dl
16551 215734 flip=0;
16552 215734 tile+=28;
16553 215734 break;
16554
16555 case r_down: //dr
16556 214874 flip=0;
16557 214874 tile+=32;
16558 214874 break;
16559 }
16560 1721294 }
16561 else
16562 {
16563 306902 tile = o_tile+((clk&2)>>1);
16564 }
16565
16566
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16567 1913340 enemy::draw(dest);
16568 2028196 }
16569
16570
16571 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16572 102 {
16573 102 adjusted=false;
16574
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16575
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16576 102 clk4 = 0;
16577 102 clk5 = 0;
16578 //flycnt=6; flycnt2=0;
16579 102 flycnt=dmisc1;
16580 102 flycnt2=0; // PatraBS doesn't have inner rings!
16581 102 loopcnt=0;
16582
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16584
16585 //nets+4480;
16586 102 }
16587
16588 35963 bool ePatraBS::animate(int32_t index)
16589 {
16590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16591
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16592 240 return Dead(index);
16593
16594
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16595 {
16596 4018 removearmos(x,y,ffcactivated);
16597 4018 }
16598
16599 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16600
16601
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16602 {
16603 336 clk2=0;
16604
16605
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16606 177 --loopcnt;
16607 else
16608 {
16609
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
16610 84 loopcnt=dmisc7;
16611 }
16612
16613 336 ++misc;
16614 336 }
16615
16616 // double size=1;;
16617
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16618 {
16619
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16620 {
16621 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16622
16623
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16624 {
16625 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16626 612 }
16627 else
16628 {
16629 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16630 }
16631
16632 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16633 612 }
16634
16635
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16636 {
16637
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16638 {
16639 131 guys.swap(j,j+1);
16640 131 }
16641
16642 104 --flycnt;
16643 104 }
16644 else
16645 {
16646 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16647
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16648 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16649 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16650
16651
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16652 {
16653 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16654
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16655 77643 }
16656 else
16657 {
16658 75725 guys.spr(i)->x = temp_x;
16659 75725 guys.spr(i)->y = temp_y;
16660 }
16661
16662 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16663 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16664
16665
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16666 {
16667 18812 guys.spr(i)->dir=l_down;
16668 18812 }
16669
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16670 {
16671 18839 guys.spr(i)->dir=left;
16672 18839 }
16673
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16674 {
16675 18802 guys.spr(i)->dir=l_up;
16676 18802 }
16677
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16678 {
16679 20143 guys.spr(i)->dir=up;
16680 20143 }
16681
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16682 {
16683 18517 guys.spr(i)->dir=r_up;
16684 18517 }
16685
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16686 {
16687 18779 guys.spr(i)->dir=right;
16688 18779 }
16689
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16690 {
16691 18992 guys.spr(i)->dir=r_down;
16692 18992 }
16693 else
16694 {
16695 20484 guys.spr(i)->dir=down;
16696 }
16697
16698 153368 guys.spr(i)->x += x;
16699 153368 guys.spr(i)->y += y;
16700 }
16701 153472 }
16702
16703 35723 adjusted=true;
16704 35723 return enemy::animate(index);
16705 35963 }
16706
16707 72874 void ePatraBS::draw(BITMAP *dest)
16708 {
16709 72874 tile=o_tile;
16710
16711
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16712 {
16713 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16714 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16715
16716
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16717 {
16718 19146 lookat=l_down;
16719 19146 }
16720
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16721 {
16722 18298 lookat=down;
16723 18298 }
16724
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16725 {
16726 13624 lookat=r_down;
16727 13624 }
16728
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16729 {
16730 7492 lookat=right;
16731 7492 }
16732
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16733 {
16734 1170 lookat=r_up;
16735 1170 }
16736
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16737 {
16738 964 lookat=up;
16739 964 }
16740
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16741 {
16742 1700 lookat=l_up;
16743 1700 }
16744 else
16745 {
16746 10480 lookat=left;
16747 }
16748
16749
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16750 {
16751 case up: //u
16752 964 flip=0;
16753 964 break;
16754
16755 case down: //d
16756 18298 flip=0;
16757 18298 tile+=8;
16758 18298 break;
16759
16760 case left: //l
16761 10480 flip=0;
16762 10480 tile+=40;
16763 10480 break;
16764
16765 case right: //r
16766 7492 flip=0;
16767 7492 tile+=48;
16768 7492 break;
16769
16770 case l_up: //ul
16771 1700 flip=0;
16772 1700 tile+=80;
16773 1700 break;
16774
16775 case r_up: //ur
16776 1170 flip=0;
16777 1170 tile+=88;
16778 1170 break;
16779
16780 case l_down: //dl
16781 19146 flip=0;
16782 19146 tile+=120;
16783 19146 break;
16784
16785 case r_down: //dr
16786 13624 flip=0;
16787 13624 tile+=128;
16788 13624 break;
16789 }
16790
16791 72874 tile+=(2*(clk&3));
16792 72874 xofs-=8;
16793 72874 yofs-=8;
16794 72874 drawblock(dest,15);
16795 72874 xofs+=8;
16796 72874 yofs+=8;
16797 72874 }
16798 else
16799 {
16800 flip=(clk&1);
16801 xofs-=8;
16802 yofs-=8;
16803 enemy::draw(dest);
16804 xofs+=16;
16805 enemy::draw(dest);
16806 yofs+=16;
16807 enemy::draw(dest);
16808 xofs-=16;
16809 enemy::draw(dest);
16810 xofs+=8;
16811 yofs-=8;
16812 }
16813 72874 }
16814
16815 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16816 {
16817 int32_t ret = enemy::defend(wpnId, power, edef);
16818
16819 if(ret < 0 && (flycnt||flycnt2))
16820 return 0;
16821
16822 return ret;
16823 }
16824
16825 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16826 {
16827 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16828
16829
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16830 81 return 0;
16831
16832 61 return ret;
16833 142 }
16834
16835 102 void ePatraBS::init_size_flags()
16836 {
16837 102 SIZEflags = d->SIZEflags;
16838
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16839 // al_trace("Enemy txsz:%i\n", txsz);
16840
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16841
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16842 102 else hit_width = 32;
16843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16846 102 else hxofs = -8;
16847
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16848 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16849
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16850
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
16851 {
16852 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16853 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16854 }
16855
16856
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16857 102 }
16858
16859 1224 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16860 612 {
16861 //cs=csBOSS;
16862 612 item_set=0;
16863 612 misc=clk;
16864 612 clk = -((misc*21)>>1)-1;
16865 612 clk4 = 0;
16866 612 clk5 = 0;
16867
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16868 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16869
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16870 // al_trace("Enemy txsz:%i\n", txsz);
16871
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16873 612 else hit_width=16;
16874
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16875 612 else hit_height=16;
16876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16877
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16879 612 else hyofs=2;
16880 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16881
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16883 {
16884 yofs = (int32_t)prntenemy->yofs;
16885 }
16886
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16887
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16888
16889 612 bgsfx=-1;
16890 612 mainguy=count_enemy=false;
16891 612 deadsfx = WAV_EDEAD;
16892 612 hitsfx = WAV_EHIT;
16893
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16894 612 isCore = false;
16895 612 }
16896
16897 155090 bool esPatraBS::animate(int32_t index)
16898 {
16899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16900
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16901 1552 return Dead(index);
16902
16903 153538 return enemy::animate(index);
16904 155090 }
16905
16906 315868 void esPatraBS::draw(BITMAP *dest)
16907 {
16908 315868 tile=o_tile;
16909
16910
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16911 {
16912
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16913 {
16914 case up: //u
16915 41612 flip=0;
16916 41612 break;
16917
16918 case down: //d
16919 42622 flip=0;
16920 42622 tile+=4;
16921 42622 break;
16922
16923 case left: //l
16924 37916 flip=0;
16925 37916 tile+=8;
16926 37916 break;
16927
16928 case right: //r
16929 38458 flip=0;
16930 38458 tile+=12;
16931 38458 break;
16932
16933 case l_up: //ul
16934 38564 flip=0;
16935 38564 tile+=20;
16936 38564 break;
16937
16938 case r_up: //ur
16939 38568 flip=0;
16940 38568 tile+=24;
16941 38568 break;
16942
16943 case l_down: //dl
16944 38662 flip=0;
16945 38662 tile+=28;
16946 38662 break;
16947
16948 case r_down: //dr
16949 39466 flip=0;
16950 39466 tile+=32;
16951 39466 break;
16952 }
16953
16954 315868 tile += ((clk&6)>>1);
16955 315868 }
16956 else
16957 {
16958 tile += (clk&4)?1:0;
16959 }
16960
16961
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16962 283752 enemy::draw(dest);
16963 315868 }
16964
16965 241822 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16966 {
16967
4/6
✓ Branch 0 taken 135636 times.
✓ Branch 1 taken 106186 times.
✓ Branch 2 taken 135636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135636 times.
✗ Branch 5 not taken.
241822 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16968
4/8
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241822 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241822 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241822 times.
✗ Branch 7 not taken.
241822 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16969
1/2
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
241822 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16970 241822 }
16971
16972 74325 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16973 {
16974 // Kludge
16975
4/8
✓ Branch 0 taken 74325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74325 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74325 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74325 times.
✗ Branch 7 not taken.
74325 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16976 74325 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74325 times.
74325 delete w;
16978 74325 return ret;
16979 }
16980
16981 9138 void enemy_scored(int32_t index)
16982 {
16983 9138 ((enemy*)guys.spr(index))->scored=true;
16984 9138 }
16985
16986 2179 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16987 {
16988
6/10
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2179 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 272 times.
✓ Branch 7 taken 1907 times.
✓ Branch 8 taken 2179 times.
✗ Branch 9 not taken.
2179 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16989
5/6
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1265 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2179 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16990 {
16991 4 g->o_tile = parentscr->guytile;
16992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16993 4 g->flags &= ~guy_invisible;
16994 4 g->cs = parentscr->guycs;
16995 4 }
16996 2179 guys.add(g);
16997 2179 }
16998
16999 23564 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17000 {
17001
4/8
✓ Branch 0 taken 23564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23564 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23564 times.
✗ Branch 7 not taken.
23564 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17002 23564 items.add(i);
17003 23564 }
17004
17005 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17006 {
17007
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17008 150 items.add(i);
17009 150 }
17010
17011 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17012 {
17013
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17014 3 items.add(i);
17015 3 }
17016
17017 96 void kill_em_all()
17018 {
17019
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
17020 {
17021 353 enemy *e = ((enemy*)guys.spr(i));
17022
17023
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17024
17025 323 e->kickbucket();
17026 323 }
17027 96 }
17028
17029 bool can_kill_em_all()
17030 {
17031 for(int32_t i=0; i<guys.Count(); i++)
17032 {
17033 enemy *e = ((enemy*)guys.spr(i));
17034
17035 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17036 if(e->superman) continue;
17037 return true;
17038 }
17039 return false;
17040 }
17041
17042 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17043 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17044 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17045 {
17046 for(int32_t i=0; i<guys.Count(); i++)
17047 {
17048 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17049 {
17050 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17051 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17052 {
17053 return i;
17054 }
17055 }
17056 }
17057
17058 return -1;
17059 }
17060
17061 13025621 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17062 {
17063
4/4
✓ Branch 0 taken 16489 times.
✓ Branch 1 taken 13009132 times.
✓ Branch 2 taken 33610047 times.
✓ Branch 3 taken 12994957 times.
46605004 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17064 {
17065
2/2
✓ Branch 0 taken 30664 times.
✓ Branch 1 taken 33579383 times.
33610047 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17066 {
17067 30664 return i;
17068 }
17069 33579383 }
17070
17071 12994957 return -1;
17072 13025621 }
17073
17074 // For Hero's hit detection. Count them if they are dying.
17075 52195 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17076 {
17077 52195 enemy *e = (enemy*)guys.spr(index);
17078
3/4
✓ Branch 0 taken 52195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27823 times.
✓ Branch 3 taken 24372 times.
52195 if(!e || e->hp > 0)
17079 27823 return -1;
17080
17081 24372 bool d = e->dying;
17082 24372 int32_t hc = e->hclk;
17083 24372 e->dying = false;
17084 24372 e->hclk = 0;
17085 24372 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17086 24372 e->dying = d;
17087 24372 e->hclk = hc;
17088
17089
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24215 times.
24372 return hit ? index : -1;
17090 52195 }
17091
17092 14185839 bool hasMainGuy()
17093 {
17094
2/2
✓ Branch 0 taken 15396025 times.
✓ Branch 1 taken 5544618 times.
20940643 for(int32_t i=0; i<guys.Count(); i++)
17095 {
17096
2/2
✓ Branch 0 taken 8641221 times.
✓ Branch 1 taken 6754804 times.
15396025 if(((enemy*)guys.spr(i))->mainguy)
17097 {
17098 8641221 return true;
17099 }
17100 6754804 }
17101
17102 5544618 return false;
17103 14185839 }
17104
17105 138 void EatHero(int32_t index)
17106 {
17107 138 ((eStalfos*)guys.spr(index))->eathero();
17108 138 }
17109
17110 9 void GrabHero(int32_t index)
17111 {
17112 9 ((eWallM*)guys.spr(index))->grabhero();
17113 9 }
17114
17115 1338 bool CarryHero()
17116 {
17117
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
17118 {
17119
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17120 {
17121
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
17122 {
17123 1338 Hero.x=guys.spr(i)->x;
17124 1338 Hero.y=guys.spr(i)->y;
17125 1338 return ((eWallM*)guys.spr(i))->misc > 0;
17126 }
17127 505 }
17128
17129 // Like Likes currently can't carry Hero.
17130 /*
17131 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17132 {
17133 if(((eLikeLike*)guys.spr(i))->hashero)
17134 {
17135 Hero.x=guys.spr(i)->x;
17136 Hero.y=guys.spr(i)->y;
17137 return (true);
17138 }
17139 }*/
17140 2595 }
17141
17142 return false;
17143 1338 }
17144
17145 // Move item with guy
17146 void movefairy(zfix &x,zfix &y,int32_t misc)
17147 {
17148 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17149
17150 if(i!=-1)
17151 {
17152 x = guys.spr(i)->x;
17153 y = guys.spr(i)->y;
17154 }
17155 }
17156
17157 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17158 void movefairy2(zfix x,zfix y,int32_t misc)
17159 {
17160 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17161
17162 if(i!=-1)
17163 {
17164 guys.spr(i)->x = x;
17165 guys.spr(i)->y = y;
17166 }
17167 }// Move item with guy
17168
17169 60438 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17170 {
17171 60438 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17172
17173
1/2
✓ Branch 0 taken 60438 times.
✗ Branch 1 not taken.
60438 if(fairy)
17174 {
17175 60438 x = fairy->x;
17176 60438 y = fairy->y;
17177 60438 }
17178 60438 }
17179
17180 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17181 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17182 {
17183 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17184
17185
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
17186 {
17187 404 fairy->x = x;
17188 404 fairy->y = y;
17189 404 }
17190 404 }
17191
17192 void killfairy(int32_t misc)
17193 {
17194 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17195 guys.del(i);
17196 }
17197
17198 217 int32_t getGuyIndex(const int32_t eid)
17199 {
17200
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 for(word i = 0; i < guys.Count(); i++)
17201 {
17202
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 609 times.
826 if(guys.spr(i)->getUID() == eid)
17203 217 return i;
17204 609 }
17205
17206 return -1;
17207 217 }
17208
17209 217 void killfairynew(item const &itemfairy)
17210 {
17211 217 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17212
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17213 217 }
17214
17215 //Should probably change this to return an 'enemy*', null on failure -Em
17216 21705 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17217 {
17218 21705 return addenemy(x,y,0,id,clk);
17219 }
17220
17221 1965 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17222 {
17223 1965 return addchild(x,y,0,id,clk, parent_scriptUID);
17224 }
17225
17226 1997 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17227 {
17228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
17229
17230 1997 int32_t ret = 0;
17231 1997 sprite *e=NULL;
17232 1997 al_trace("Adding child\n");
17233
17234
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17235 {
17236 //Fixme: possible enemy memory leak. (minor)
17237 case eeWALK:
17238
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17239 110 break;
17240
17241 case eeLEV:
17242 e = new eLeever((zfix)x,(zfix)y,id,clk);
17243 break;
17244
17245 case eeTEK:
17246 e = new eTektite((zfix)x,(zfix)y,id,clk);
17247 break;
17248
17249 case eePEAHAT:
17250 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17251 break;
17252
17253 case eeZORA:
17254 e = new eZora((zfix)x,(zfix)y,id,clk);
17255 break;
17256
17257 case eeGHINI:
17258 e = new eGhini((zfix)x,(zfix)y,id,clk);
17259 break;
17260
17261 case eeKEESE:
17262
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17263 1865 break;
17264
17265 case eeWIZZ:
17266
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17267 15 break;
17268
17269 case eePROJECTILE:
17270 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17271 break;
17272
17273 case eeWALLM:
17274 e = new eWallM((zfix)x,(zfix)y,id,clk);
17275 break;
17276
17277 case eeAQUA:
17278 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17279 break;
17280
17281 case eeMOLD:
17282 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17283 break;
17284
17285 case eeMANHAN:
17286
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17287 1 break;
17288
17289 case eeGLEEOK:
17290 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17291 break;
17292
17293 case eeGHOMA:
17294 e = new eGohma((zfix)x,(zfix)y,id,clk);
17295 break;
17296
17297 case eeLANM:
17298 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17299 break;
17300
17301 case eeGANON:
17302 e = new eGanon((zfix)x,(zfix)y,id,clk);
17303 break;
17304
17305 case eeFAIRY:
17306 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17307 break;
17308
17309 case eeFIRE:
17310
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17311 2 break;
17312
17313 case eeOTHER:
17314 e = new eOther((zfix)x,(zfix)y,id,clk);
17315 break;
17316
17317
17318 case eeSCRIPT01:
17319 case eeSCRIPT02:
17320 case eeSCRIPT03:
17321 case eeSCRIPT04:
17322 case eeSCRIPT05:
17323 case eeSCRIPT06:
17324 case eeSCRIPT07:
17325 case eeSCRIPT08:
17326 case eeSCRIPT09:
17327 case eeSCRIPT10:
17328 case eeSCRIPT11:
17329 case eeSCRIPT12:
17330 case eeSCRIPT13:
17331 case eeSCRIPT14:
17332 case eeSCRIPT15:
17333 case eeSCRIPT16:
17334 case eeSCRIPT17:
17335 case eeSCRIPT18:
17336 case eeSCRIPT19:
17337 case eeSCRIPT20:
17338 {
17339 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17340 {
17341 e = new eScript((zfix)x,(zfix)y,id,clk);
17342 break;
17343 }
17344 else return 0;
17345 }
17346
17347 case eeFFRIENDLY01:
17348 case eeFFRIENDLY02:
17349 case eeFFRIENDLY03:
17350 case eeFFRIENDLY04:
17351 case eeFFRIENDLY05:
17352 case eeFFRIENDLY06:
17353 case eeFFRIENDLY07:
17354 case eeFFRIENDLY08:
17355 case eeFFRIENDLY09:
17356 case eeFFRIENDLY10:
17357 {
17358 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17359 {
17360 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17361 }
17362 else return 0;
17363
17364 }
17365
17366 case eeSPINTILE:
17367 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17368 break;
17369
17370 // and these enemies use the misc10/misc2 value
17371 case eeROCK:
17372 {
17373 switch(guysbuf[id&0xFFF].attributes[9])
17374 {
17375 case 1:
17376 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17377 break;
17378
17379 case 0:
17380 default:
17381 e = new eRock((zfix)x,(zfix)y,id,clk);
17382 break;
17383 }
17384
17385 break;
17386 }
17387
17388 case eeTRAP:
17389 {
17390 switch(guysbuf[id&0xFFF].attributes[1])
17391 {
17392 case 1:
17393 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17394 break;
17395
17396 case 0:
17397 default:
17398 e = new eTrap((zfix)x,(zfix)y,id,clk);
17399 break;
17400 }
17401
17402 break;
17403 }
17404
17405 case eeDONGO:
17406 {
17407 switch(guysbuf[id&0xFFF].attributes[9])
17408 {
17409 case 1:
17410 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17411 break;
17412
17413 case 0:
17414 default:
17415 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17416 break;
17417 }
17418
17419 break;
17420 }
17421
17422 case eeDIG:
17423 {
17424
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17425 {
17426 case 1:
17427 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17428 break;
17429
17430 4 case 0:
17431 default:
17432
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17433 4 break;
17434 }
17435
17436 4 break;
17437 }
17438
17439 case eePATRA:
17440 {
17441 switch(guysbuf[id&0xFFF].attributes[9])
17442 {
17443 case 1:
17444 if (get_qr(qr_HARDCODED_BS_PATRA))
17445 {
17446 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17447 break;
17448 }
17449 [[fallthrough]];
17450 case 0:
17451 default:
17452 e = new ePatra((zfix)x,(zfix)y,id,clk);
17453 break;
17454 }
17455
17456 break;
17457 }
17458
17459 case eeGUY:
17460 {
17461 switch(guysbuf[id&0xFFF].attributes[9])
17462 {
17463 case 1:
17464 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17465 break;
17466
17467 case 0:
17468 default:
17469 e = new eNPC((zfix)x,(zfix)y,id,clk);
17470 break;
17471 }
17472
17473 break;
17474 }
17475
17476 case eeNONE:
17477 if(guysbuf[id&0xFFF].attributes[9] ==1)
17478 {
17479 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17480 break;
17481 break;
17482 }
17483 [[fallthrough]];
17484 default:
17485
17486 return 0;
17487 }
17488
17489 1997 ret++; // Made one enemy.
17490
17491
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17492 {
17493 7 e->z = (zfix)z;
17494 7 }
17495
17496
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17497 1997 ((enemy*)e)->parent_script_UID = parent_scriptUID;
17498
17499
17500
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17501 {
17502 return 0;
17503 }
17504
17505 // add segments of segmented enemies
17506 1997 int32_t c=0;
17507
17508
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17509 {
17510 case eeMOLD:
17511 {
17512 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17513 id &= 0xFFF;
17514
17515 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17516 {
17517 //christ this is messy -DD
17518 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17519
17520 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17521 {
17522 al_trace("Moldorm segment %d could not be created!\n",i+1);
17523
17524 for(int32_t j=0; j<i+1; j++)
17525 guys.del(guys.Count()-1);
17526
17527 return 0;
17528 }
17529
17530 if(i>0)
17531 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17532
17533 ret++;
17534 }
17535
17536 break;
17537 }
17538
17539 case eeLANM:
17540 {
17541 id &= 0xFFF;
17542 int32_t shft = guysbuf[id].attributes[1];
17543 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17544
17545 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17546 {
17547 al_trace("Lanmola segment 1 could not be created!\n");
17548 guys.del(guys.Count()-1);
17549 return 0;
17550 }
17551
17552 ret++;
17553
17554 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17555 {
17556 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17557 {
17558 al_trace("Lanmola segment %d could not be created!\n",i+1);
17559
17560 for(int32_t j=0; j<i+1; j++)
17561 guys.del(guys.Count()-1);
17562
17563 return 0;
17564 }
17565
17566 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17567 ret++;
17568 }
17569 }
17570 break;
17571
17572 case eeMANHAN:
17573 1 id &= 0xFFF;
17574
17575
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17576 {
17577
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17578 {
17579 al_trace("Manhandla head %d could not be created!\n",i+1);
17580
17581 for(int32_t j=0; j<i+1; j++)
17582 {
17583 guys.del(guys.Count()-1);
17584 }
17585
17586 return 0;
17587 }
17588
17589 4 ret++;
17590 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17591 4 }
17592
17593 1 break;
17594
17595 case eeGLEEOK:
17596 {
17597 id &= 0xFFF;
17598
17599 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17600 {
17601 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17602 {
17603 al_trace("Gleeok head %d could not be created!\n",i+1);
17604
17605 for(int32_t j=0; j<i+1; j++)
17606 {
17607 guys.del(guys.Count()-1);
17608 }
17609
17610 return false;
17611 }
17612
17613 c-=guysbuf[id].attributes[3];
17614 ret++;
17615 }
17616 }
17617 break;
17618
17619
17620 case eePATRA:
17621 {
17622 id &= 0xFFF;
17623 int32_t outeyes = 0;
17624
17625 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17626 {
17627 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17628 {
17629 al_trace("Patra outer eye %d could not be created!\n",i+1);
17630
17631 for(int32_t j=0; j<i+1; j++)
17632 guys.del(guys.Count()-1);
17633
17634 return 0;
17635 }
17636 else
17637 outeyes++;
17638
17639 ret++;
17640 }
17641
17642 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17643 {
17644 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17645 {
17646 al_trace("Patra inner eye %d could not be created!\n",i+1);
17647
17648 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17649 guys.del(guys.Count()-1);
17650
17651 return 0;
17652 }
17653
17654 ret++;
17655 }
17656
17657 break;
17658 }
17659 }
17660
17661 1997 return ret;
17662 1997 }
17663
17664 // Returns number of enemies/segments created
17665 101436 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17666 {
17667 101436 int32_t realid = id&0xFFF;
17668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101436 times.
101436 if( realid > MAXGUYS )
17669 {
17670 return 0;
17671 }
17672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101436 times.
101436 if(id <= 0) return 0;
17673
17674 101436 int32_t ret = 0;
17675 101436 sprite *e=NULL;
17676
17677
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50006 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5196 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2765 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11717 times.
✓ Branch 10 taken 5311 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 730 times.
✓ Branch 21 taken 761 times.
✓ Branch 22 taken 7314 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2432 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
101436 switch(guysbuf[id&0xFFF].family)
17678 {
17679 //Fixme: possible enemy memory leak. (minor)
17680 case eeWALK:
17681
3/6
✓ Branch 0 taken 50006 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50006 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50006 times.
✗ Branch 5 not taken.
50006 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17682 50006 break;
17683
17684 case eeLEV:
17685
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17686 3942 break;
17687
17688 case eeTEK:
17689
3/6
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5196 times.
✗ Branch 5 not taken.
5196 e = new eTektite((zfix)x,(zfix)y,id,clk);
17690 5196 break;
17691
17692 case eePEAHAT:
17693
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17694 1825 break;
17695
17696 case eeZORA:
17697
3/6
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2765 times.
✗ Branch 5 not taken.
2765 e = new eZora((zfix)x,(zfix)y,id,clk);
17698 2765 break;
17699
17700 case eeGHINI:
17701
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17702 461 break;
17703
17704 case eeKEESE:
17705
3/6
✓ Branch 0 taken 11717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11717 times.
✗ Branch 5 not taken.
11717 e = new eKeese((zfix)x,(zfix)y,id,clk);
17706 11717 break;
17707
17708 case eeWIZZ:
17709
3/6
✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5311 times.
✗ Branch 5 not taken.
5311 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17710 5311 break;
17711
17712 case eePROJECTILE:
17713
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17714 4429 break;
17715
17716 case eeWALLM:
17717
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17718 998 break;
17719
17720 case eeAQUA:
17721
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17722 126 break;
17723
17724 case eeMOLD:
17725
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17726 618 break;
17727
17728 case eeMANHAN:
17729
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17730 149 break;
17731
17732 case eeGLEEOK:
17733
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17734 168 break;
17735
17736 case eeGHOMA:
17737
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17738 93 break;
17739
17740 case eeLANM:
17741
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17742 420 break;
17743
17744 case eeGANON:
17745
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17746 13 break;
17747
17748 case eeFAIRY:
17749
3/6
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 730 times.
✗ Branch 5 not taken.
730 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17750 730 break;
17751
17752 case eeFIRE:
17753
3/6
✓ Branch 0 taken 761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 761 times.
✗ Branch 5 not taken.
761 e = new eFire((zfix)x,(zfix)y,id,clk);
17754 761 break;
17755
17756 case eeOTHER:
17757
3/6
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
7314 e = new eOther((zfix)x,(zfix)y,id,clk);
17758 7314 break;
17759
17760
17761 case eeSCRIPT01:
17762 case eeSCRIPT02:
17763 case eeSCRIPT03:
17764 case eeSCRIPT04:
17765 case eeSCRIPT05:
17766 case eeSCRIPT06:
17767 case eeSCRIPT07:
17768 case eeSCRIPT08:
17769 case eeSCRIPT09:
17770 case eeSCRIPT10:
17771 case eeSCRIPT11:
17772 case eeSCRIPT12:
17773 case eeSCRIPT13:
17774 case eeSCRIPT14:
17775 case eeSCRIPT15:
17776 case eeSCRIPT16:
17777 case eeSCRIPT17:
17778 case eeSCRIPT18:
17779 case eeSCRIPT19:
17780 case eeSCRIPT20:
17781 {
17782 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17783 {
17784 e = new eScript((zfix)x,(zfix)y,id,clk);
17785 break;
17786 }
17787 else return 0;
17788 }
17789
17790 case eeFFRIENDLY01:
17791 case eeFFRIENDLY02:
17792 case eeFFRIENDLY03:
17793 case eeFFRIENDLY04:
17794 case eeFFRIENDLY05:
17795 case eeFFRIENDLY06:
17796 case eeFFRIENDLY07:
17797 case eeFFRIENDLY08:
17798 case eeFFRIENDLY09:
17799 case eeFFRIENDLY10:
17800 {
17801 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17802 {
17803 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17804 }
17805 else return 0;
17806
17807 }
17808
17809 case eeSPINTILE:
17810
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17811 94 break;
17812
17813 // and these enemies use the misc10/misc2 value
17814 case eeROCK:
17815 {
17816
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17817 {
17818 case 1:
17819
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17820 30 break;
17821
17822 354 case 0:
17823 default:
17824
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17825 354 break;
17826 }
17827
17828 384 break;
17829 }
17830
17831 case eeTRAP:
17832 {
17833
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1600 times.
2432 switch(guysbuf[id&0xFFF].attributes[1])
17834 {
17835 case 1:
17836
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17837 832 break;
17838
17839 1600 case 0:
17840 default:
17841
3/6
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600 times.
✗ Branch 5 not taken.
1600 e = new eTrap((zfix)x,(zfix)y,id,clk);
17842 1600 break;
17843 }
17844
17845 2432 break;
17846 }
17847
17848 case eeDONGO:
17849 {
17850
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17851 {
17852 case 1:
17853
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17854 48 break;
17855
17856 203 case 0:
17857 default:
17858
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17859 203 break;
17860 }
17861
17862 251 break;
17863 }
17864
17865 case eeDIG:
17866 {
17867
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17868 {
17869 case 1:
17870
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17871 327 break;
17872
17873 76 case 0:
17874 default:
17875
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17876 76 break;
17877 }
17878
17879 403 break;
17880 }
17881
17882 case eePATRA:
17883 {
17884
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17885 {
17886 case 1:
17887
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17888 {
17889
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17890 102 break;
17891 }
17892 [[fallthrough]];
17893 190 case 0:
17894 default:
17895
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17896 190 break;
17897 }
17898
17899 292 break;
17900 }
17901
17902 case eeGUY:
17903 {
17904
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17905 {
17906 case 1:
17907 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17908 break;
17909
17910 5 case 0:
17911 default:
17912
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17913 5 break;
17914 }
17915
17916 5 break;
17917 }
17918
17919 case eeNONE:
17920
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17921 {
17922
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17923 533 break;
17924 break;
17925 }
17926 [[fallthrough]];
17927 default:
17928
17929 return 0;
17930 }
17931
17932 101436 ret++; // Made one enemy.
17933
17934
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 101305 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 106 times.
101436 if(z && canfall(id))
17935 {
17936 106 e->z = (zfix)z;
17937 106 }
17938
17939
2/2
✓ Branch 0 taken 101305 times.
✓ Branch 1 taken 131 times.
101436 ((enemy*)e)->ceiling = (z && canfall(id));
17940
17941
1/2
✓ Branch 0 taken 101436 times.
✗ Branch 1 not taken.
101436 if(!guys.add(e))
17942 {
17943 return 0;
17944 }
17945
17946 // add segments of segmented enemies
17947 101436 int32_t c=0;
17948
17949
6/6
✓ Branch 0 taken 99789 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
101436 switch(guysbuf[id&0xFFF].family)
17950 {
17951 case eeMOLD:
17952 {
17953 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17954 618 id &= 0xFFF;
17955
17956
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17957 {
17958 //christ this is messy -DD
17959 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17960
17961
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17962 {
17963 al_trace("Moldorm segment %d could not be created!\n",i+1);
17964
17965 for(int32_t j=0; j<i+1; j++)
17966 guys.del(guys.Count()-1);
17967
17968 return 0;
17969 }
17970
17971
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17972 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17973
17974 3150 ret++;
17975 3150 }
17976
17977 618 break;
17978 }
17979
17980 case eeLANM:
17981 {
17982 420 id &= 0xFFF;
17983 420 int32_t shft = guysbuf[id].attributes[1];
17984 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17985
17986
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17987 {
17988 al_trace("Lanmola segment 1 could not be created!\n");
17989 guys.del(guys.Count()-1);
17990 return 0;
17991 }
17992
17993 420 ret++;
17994
17995
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17996 {
17997
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17998 {
17999 al_trace("Lanmola segment %d could not be created!\n",i+1);
18000
18001 for(int32_t j=0; j<i+1; j++)
18002 guys.del(guys.Count()-1);
18003
18004 return 0;
18005 }
18006
18007 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18008 1847 ret++;
18009 1847 }
18010 }
18011 420 break;
18012
18013 case eeMANHAN:
18014 149 id &= 0xFFF;
18015
18016
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
18017 {
18018
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18019 {
18020 al_trace("Manhandla head %d could not be created!\n",i+1);
18021
18022 for(int32_t j=0; j<i+1; j++)
18023 {
18024 guys.del(guys.Count()-1);
18025 }
18026
18027 return 0;
18028 }
18029
18030 688 ret++;
18031 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
18032 688 }
18033
18034 149 break;
18035
18036 case eeGLEEOK:
18037 {
18038 168 id &= 0xFFF;
18039 168 eGleeok* parent = (eGleeok*)e;
18040
18041
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
18042 {
18043
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18044
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
18045 {
18046 al_trace("Gleeok head %d could not be created!\n",i+1);
18047
18048 for(int32_t j=0; j<i+1; j++)
18049 {
18050 guys.del(guys.Count()-1);
18051 }
18052
18053 return false;
18054 }
18055
18056 533 head->necktile=parent->necktile;
18057 533 head->dummy_int[1]=parent->necktile;
18058
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
18059 {
18060 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18061 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18062 421 }
18063 else
18064 {
18065 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
18066 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
18067 }
18068 533 head->tile = head->dummy_int[2];
18069
18070 533 c-=guysbuf[id].attributes[3];
18071 533 ret++;
18072 533 }
18073 }
18074 168 break;
18075
18076
18077 case eePATRA:
18078 {
18079 292 id &= 0xFFF;
18080 292 int32_t outeyes = 0;
18081
18082
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
18083 {
18084
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18085 {
18086 al_trace("Patra outer eye %d could not be created!\n",i+1);
18087
18088 for(int32_t j=0; j<i+1; j++)
18089 guys.del(guys.Count()-1);
18090
18091 return 0;
18092 }
18093 else
18094 1956 outeyes++;
18095
18096 1956 ret++;
18097 1956 }
18098
18099
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
18100 {
18101
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18102 {
18103 al_trace("Patra inner eye %d could not be created!\n",i+1);
18104
18105 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18106 guys.del(guys.Count()-1);
18107
18108 return 0;
18109 }
18110
18111 312 ret++;
18112 312 }
18113
18114 292 break;
18115 }
18116 }
18117
18118 101436 return ret;
18119 101436 }
18120
18121 1854532 bool isjumper(int32_t id)
18122 {
18123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1854532 times.
1854532 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18124 {
18125 return false;
18126 }
18127
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1750545 times.
✓ Branch 2 taken 103978 times.
1854532 switch(guysbuf[id&0xFFF].family)
18128 {
18129 case eeROCK:
18130 case eeTEK:
18131 9 return true;
18132
18133 case eeWALK:
18134
3/4
✓ Branch 0 taken 103978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 91713 times.
103978 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
18135 91713 }
18136
18137 1842258 return false;
18138 1854532 }
18139
18140
18141 291817 bool isfixedtogrid(int32_t id)
18142 {
18143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291817 times.
291817 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18144 {
18145 return false;
18146 }
18147
1/2
✓ Branch 0 taken 291817 times.
✗ Branch 1 not taken.
291817 switch(guysbuf[id&0xFFF].family)
18148 {
18149 case eeWALK:
18150 case eeLEV:
18151 case eeZORA:
18152 case eeDONGO:
18153 case eeGANON:
18154 case eeROCK:
18155 case eeGLEEOK:
18156 case eeAQUA:
18157 case eeLANM:
18158 return true;
18159 }
18160
18161 291817 return false;
18162 291817 }
18163
18164 // Can't fall, can have Z value.
18165 51785071 bool isflier(int32_t id)
18166 {
18167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51785071 times.
51785071 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18168 {
18169 return false;
18170 }
18171
2/2
✓ Branch 0 taken 45356705 times.
✓ Branch 1 taken 6428366 times.
51785071 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18172 {
18173 case eePEAHAT:
18174 case eeKEESE:
18175 case eePATRA:
18176 case eeFAIRY:
18177 case eeGHINI:
18178
18179 // Could theoretically have their Z set by a script
18180 case eeFIRE:
18181 6428366 return true;
18182 break;
18183 }
18184
18185 45356705 return false;
18186 51785071 }
18187
18188 // Can't have Z position
18189 3714963 bool never_in_air(int32_t id)
18190 {
18191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3714963 times.
3714963 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18192 {
18193 return false;
18194 }
18195
2/2
✓ Branch 0 taken 3705413 times.
✓ Branch 1 taken 9550 times.
3714963 switch(guysbuf[id&0xFFF].family)
18196 {
18197 case eeMANHAN:
18198 case eeMOLD:
18199 case eeLANM:
18200 case eeGLEEOK:
18201 case eeZORA:
18202 case eeLEV:
18203 case eeAQUA:
18204 case eeROCK:
18205 case eeGANON:
18206 case eeTRAP:
18207 case eePROJECTILE:
18208 case eeSPINTILE:
18209 9550 return true;
18210 }
18211
18212 3705413 return false;
18213 3714963 }
18214
18215 2015293 bool canfall(int32_t id)
18216 {
18217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2015293 times.
2015293 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18218 {
18219 return false;
18220 }
18221
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2015253 times.
✓ Branch 2 taken 40 times.
2015293 switch(guysbuf[id&0xFFF].family)
18222 {
18223 case eeGUY:
18224 {
18225
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
18226 40 return false;
18227
18228 switch(guysbuf[id&0xFFF].attributes[9])
18229 {
18230 case 1:
18231 case 2:
18232 return true;
18233
18234 case 0:
18235 case 3:
18236 default:
18237 return false;
18238 }
18239
18240 case eeGHOMA:
18241 case eeDIG:
18242 return false;
18243 }
18244 }
18245
18246
18247
4/4
✓ Branch 0 taken 2006817 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 152285 times.
✓ Branch 3 taken 1854532 times.
2015253 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18248 2015293 }
18249
18250 73542396 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18251 {
18252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73542396 times.
73542396 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18253 {
18254 return false;
18255 }
18256 //Z_scripterrlog("canfall family is %d:\n", family);
18257 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
18258 //if ( family == eeFIRE && id >= eSTART )
18259 //{
18260 // Z_scripterrlog("eeFire\n");
18261 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
18262 //}
18263
18264 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18265
18266
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71046567 times.
✓ Branch 2 taken 2066894 times.
73542396 switch(guysbuf[id&0xFFF].family)
18267 {
18268 case eeGUY:
18269 {
18270
1/2
✓ Branch 0 taken 2066894 times.
✗ Branch 1 not taken.
2066894 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18271 2066894 return false;
18272
18273 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18274 {
18275 case 1:
18276 case 2:
18277 return true;
18278
18279 case 0:
18280 case 3:
18281 default:
18282 return false;
18283 }
18284
18285 case eeGHOMA:
18286 case eeDIG:
18287 428935 return false;
18288 }
18289 }
18290
18291
2/2
✓ Branch 0 taken 38947783 times.
✓ Branch 1 taken 32098784 times.
71046567 if(!checkgrav) return true;
18292 38947783 return (moveflags & move_obeys_grav);
18293
18294 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18295 // {
18296 // if ( moveflags & move_obeys_grav ) return true;
18297 // else return false;
18298 // }
18299 // else
18300 // {
18301 // return (moveflags & move_obeys_grav);
18302 // }
18303 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18304 73542396 }
18305
18306 1266 void addfires()
18307 {
18308
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 455 times.
1266 if(!get_qr(qr_NOGUYFIRES))
18309 {
18310 455 int32_t bs = get_qr(qr_BSZELDA);
18311 455 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18312 455 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18313 455 }
18314 1266 }
18315
18316 35264 void loadguys()
18317 {
18318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35264 times.
35264 if(loaded_guys)
18319 return;
18320
18321 35264 loaded_guys=true;
18322
18323 35264 byte Guy=0;
18324 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18325 // Else use mITEM and ipONETIME
18326 35264 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18327 35264 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18328
18329 35264 repaircharge=0;
18330 35264 adjustmagic=false;
18331 35264 learnslash=false;
18332
18333
2/2
✓ Branch 0 taken 105792 times.
✓ Branch 1 taken 35264 times.
141056 for(int32_t i=0; i<3; i++)
18334 {
18335 105792 prices[i]=0;
18336 105792 }
18337
18338 35264 hasitem=0;
18339
18340 35264 mapscr* guyscr = tmpscr;
18341
4/4
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 429 times.
35264 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18342 {
18343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(DMaps[currdmap].flags&dmfCAVES)
18344 {
18345 429 Guy=tmpscr[1].guy;
18346 429 guyscr = tmpscr+1;
18347 429 }
18348 429 }
18349 else
18350 {
18351 34835 Guy=tmpscr->guy;
18352
18353
4/4
✓ Branch 0 taken 34360 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 24138 times.
✓ Branch 3 taken 10222 times.
34835 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18354 10222 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18355 }
18356
18357 35264 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18358 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18359
4/4
✓ Branch 0 taken 3845 times.
✓ Branch 1 taken 31419 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 1307 times.
35264 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18360 {
18361
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1295 times.
1307 if(tmpscr->room==rZELDA)
18362 {
18363 12 addguy(120,72,Guy,-15,true,guyscr);
18364 12 guys.spr(0)->hxofs=1000;
18365 12 addenemy(128,96,eFIRE,-15);
18366 12 addenemy(112,96,eFIRE,-15);
18367 12 addenemy(96,120,eFIRE,-15);
18368 12 addenemy(144,120,eFIRE,-15);
18369 12 return;
18370 }
18371
18372
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 4 times.
2586 bool ffire = oldguy
18373
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 25 times.
1291 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18374 4 : (guyscr->roomflags&RFL_GUYFIRES);
18375
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1266 times.
1295 if(ffire)
18376 1266 addfires();
18377
18378
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 423 times.
1295 if(currscr>=128)
18379
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
436 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18380 13 Guy=0;
18381
18382
4/6
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1083 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1295 switch(tmpscr->room)
18383 {
18384 case rSP_ITEM:
18385 case rGRUMBLE:
18386 case rBOMBS:
18387 case rARROWS:
18388 case rSWINDLE:
18389 case rMUPGRADE:
18390 case rLEARNSLASH:
18391 case rTAKEONE:
18392
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 41 times.
166 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18393 55 Guy=0;
18394
18395 166 break;
18396
18397 case rREPAIR:
18398 if (get_qr(qr_OLD_DOORREPAIR)) break;
18399 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18400 Guy=0;
18401
18402 break;
18403 case rRP_HC:
18404 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18405 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18406 Guy=0;
18407
18408 break;
18409 case rMONEY:
18410
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18411 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18412 Guy=0;
18413
18414 break;
18415
18416 case rTRIFORCE:
18417 {
18418 45 int32_t tc = TriforceCount();
18419
18420
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18421 {
18422
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18423 10 Guy=0;
18424 9 }
18425 else
18426 {
18427
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18428 33 Guy=0;
18429 }
18430 }
18431 43 break;
18432 }
18433
18434
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1186 times.
1293 if(Guy)
18435 {
18436
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1157 times.
1186 if(ffire)
18437 1157 blockpath=true;
18438
18439
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 776 times.
1186 if(currscr<128)
18440 776 sfx(WAV_SCALE);
18441
18442
4/4
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 727 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 355 times.
1186 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18443 1186 Hero.Freeze();
18444 1186 }
18445 1293 }
18446
5/6
✓ Branch 0 taken 32168 times.
✓ Branch 1 taken 1789 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32097 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1789 times.
33957 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18447 {
18448 71 sfx(WAV_SCALE);
18449 71 addguy(120,62,Guy,-14,false,guyscr);
18450 71 }
18451
18452 35250 loaditem();
18453
18454 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18455 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18456
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 35231 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
35250 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18457 {
18458 //setmapflag();
18459
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18460 150 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18461 15 }
18462 35262 }
18463
18464 35269 void loaditem()
18465 {
18466 35269 byte Item = 0;
18467
18468
2/2
✓ Branch 0 taken 34365 times.
✓ Branch 1 taken 904 times.
35269 if(currscr<128)
18469 {
18470 34365 Item=tmpscr->item;
18471
18472
4/4
✓ Branch 0 taken 1580 times.
✓ Branch 1 taken 32785 times.
✓ Branch 2 taken 31338 times.
✓ Branch 3 taken 3027 times.
34365 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18473 {
18474
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2968 times.
3027 if(tmpscr->flags8&fSECRETITEM)
18475 59 hasitem=8;
18476
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 1811 times.
2968 else if(tmpscr->flags&fITEM)
18477 1157 hasitem=1;
18478
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1747 times.
1811 else if(tmpscr->enemyflags&efCARRYITEM)
18479 64 hasitem=4; // Will be set to 2 by roaming_item
18480 else
18481
2/4
✓ Branch 0 taken 1747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1747 times.
✗ Branch 3 not taken.
3494 items.add(new item((zfix)tmpscr->itemx,
18482
6/12
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1732 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1747 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1747 times.
✗ Branch 11 not taken.
1747 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18483
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1732 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1732 times.
✗ Branch 9 not taken.
1747 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18484
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1642 times.
1747 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18485 1747 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18486 3027 }
18487 34365 }
18488
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 else if(!(DMaps[currdmap].flags&dmfCAVES))
18489 {
18490
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
18491
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18492 {
18493 163 Item=tmpscr[1].catchall;
18494
18495
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18496
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
324 items.add(new item((zfix)tmpscr->itemx,
18497
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 162 times.
✗ Branch 11 not taken.
162 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18498
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18499 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18500 163 }
18501 475 }
18502 35269 }
18503
18504 957 void never_return(int32_t index)
18505 {
18506
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18507 191 goto doit;
18508
18509
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18510
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18511 {
18512 437 goto dontdoit;
18513 329 }
18514
18515 doit:
18516 520 setmapflag(mNEVERRET);
18517 dontdoit:
18518 957 return;
18519 }
18520
18521 63438 bool slowguy(int32_t id)
18522 {
18523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63438 times.
63438 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18524 {
18525 return false;
18526 }
18527 //return (guysbuf[id].step<100);
18528
2/2
✓ Branch 0 taken 53854 times.
✓ Branch 1 taken 9584 times.
63438 switch(id)
18529 {
18530 case eOCTO1S:
18531 case eOCTO2S:
18532 case eOCTO1F:
18533 case eOCTO2F:
18534 case eLEV1:
18535 case eLEV2:
18536 case eROCK:
18537 case eBOULDER:
18538 9584 return true;
18539 }
18540
18541 53854 return false;
18542 63438 }
18543
18544 82773 bool ok2add(int32_t id)
18545 {
18546
2/4
✓ Branch 0 taken 82773 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82773 times.
82773 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
18547 {
18548 return false;
18549 }
18550
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 81944 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
82773 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18551 464 return false;
18552
18553
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81668 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82309 switch(guysbuf[id].family)
18554 {
18555 // I added a special case for shooters because having traps on the same screen
18556 // was preventing them from spawning due to TMPNORET. This means they will
18557 // never stay dead, though, so it may not be the best solution. - Saf
18558 case eePROJECTILE:
18559 376 return true;
18560
18561
18562 case eeDIG:
18563 {
18564
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18565 {
18566 case 1:
18567
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18568 79 return !getmapflag(mTMPNORET);
18569
18570 47 return true;
18571
18572 75 case 0:
18573 default:
18574 75 return true;
18575 }
18576 }
18577 case eeGANON:
18578 case eeTRAP:
18579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18580
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18581 [[fallthrough]];
18582 default:
18583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81668 times.
81668 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18584 81668 break;
18585 }
18586
18587
2/2
✓ Branch 0 taken 20881 times.
✓ Branch 1 taken 60787 times.
81668 if(!get_qr(qr_NOTMPNORET))
18588 60787 return !getmapflag(mTMPNORET);
18589
18590 20881 return true;
18591 82773 }
18592
18593 1408985 void activate_fireball_statue(int32_t pos)
18594 {
18595
3/4
✓ Branch 0 taken 287785 times.
✓ Branch 1 taken 1121200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287785 times.
1408985 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
18596 {
18597 1121200 return;
18598 }
18599
18600 287785 int32_t cx=-1000, cy=-1000;
18601 287785 int32_t x = (pos&15)<<4;
18602 287785 int32_t y = pos&0xF0;
18603
18604 287785 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18605
18606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287785 times.
287785 if(!isfixedtogrid(statueID))
18607 {
18608
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 286277 times.
287785 if(ctype==cL_STATUE)
18609 {
18610 1508 cx=x+4;
18611 1508 cy=y+7;
18612 1508 }
18613
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 284962 times.
286277 else if(ctype==cR_STATUE)
18614 {
18615 1315 cx=x-8;
18616 1315 cy=y-1;
18617 1315 }
18618
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 1213 times.
284962 else if(ctype==cC_STATUE)
18619 {
18620 1213 cx=x;
18621 1213 cy=y;
18622 1213 }
18623 287785 }
18624 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18625 {
18626 cx=x;
18627 cy=y;
18628 }
18629
18630
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 4036 times.
287785 if(cx!=-1000) // No point creating it if this is false
18631 {
18632
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18633 {
18634
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18635 {
18636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18637 4 return; // No point deleting it. A script might be toying with it in some way.
18638 else
18639 guys.del(j);
18640 }
18641 9750 }
18642
18643 4032 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18644 4032 }
18645 1408985 }
18646
18647 34961 void activate_fireball_statues()
18648 {
18649
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 33548 times.
34961 if(!(tmpscr->enemyflags&efFIREBALLS))
18650 {
18651 33548 return;
18652 }
18653
18654
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 248688 times.
250101 for(int32_t i=0; i<176; i++)
18655 {
18656 248688 activate_fireball_statue(i);
18657 248688 }
18658 34961 }
18659
18660 34961 void load_default_enemies()
18661 {
18662 34961 wallm_load_clk=frame-80;
18663
18664
2/2
✓ Branch 0 taken 33081 times.
✓ Branch 1 taken 1880 times.
34961 if(tmpscr->enemyflags&efZORA)
18665 {
18666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1880 times.
1880 if(zoraID>=0)
18667 1880 addenemy(-16, -16, zoraID, 0);
18668 1880 }
18669
18670
2/2
✓ Branch 0 taken 34783 times.
✓ Branch 1 taken 178 times.
34961 if(tmpscr->enemyflags&efTRAP4)
18671 {
18672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18673 {
18674 178 addenemy(32, 32, cornerTrapID, -14);
18675 178 addenemy(208, 32, cornerTrapID, -14);
18676 178 addenemy(32, 128, cornerTrapID, -14);
18677 178 addenemy(208, 128, cornerTrapID, -14);
18678 178 }
18679 178 }
18680
18681
2/2
✓ Branch 0 taken 384571 times.
✓ Branch 1 taken 34961 times.
419532 for(int32_t y=0; y<176; y+=16)
18682 {
18683
2/2
✓ Branch 0 taken 6153136 times.
✓ Branch 1 taken 384571 times.
6537707 for(int32_t x=0; x<256; x+=16)
18684 {
18685 6153136 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18686 6153136 int32_t cflag = MAPFLAG(x, y);
18687 6153136 int32_t cflag_i = MAPCOMBOFLAG(x, y);
18688
18689
4/6
✓ Branch 0 taken 6153136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152830 times.
✓ Branch 3 taken 306 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6152830 times.
6153136 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18690 {
18691
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 296 times.
306 if(trapLOSHorizontalID>=0)
18692 296 addenemy(x, y, trapLOSHorizontalID, -14);
18693 306 }
18694
4/6
✓ Branch 0 taken 6152830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152624 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6152624 times.
6152830 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18695 {
18696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18697 206 addenemy(x, y, trapLOSVerticalID, -14);
18698 206 }
18699
4/6
✓ Branch 0 taken 6152624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152346 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6152346 times.
6152624 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18700 {
18701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18702 {
18703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(addenemy(x, y, trapLOS4WayID, -14))
18704 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18705 278 }
18706 278 }
18707
18708
4/6
✓ Branch 0 taken 6152346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151947 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151947 times.
6152346 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18709 {
18710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18711 399 addenemy(x, y, trapConstantHorizontalID, -14);
18712 399 }
18713
4/6
✓ Branch 0 taken 6151947 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151514 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151514 times.
6151947 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18714 {
18715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18716 433 addenemy(x, y, trapConstantVerticalID, -14);
18717 433 }
18718
18719
1/2
✓ Branch 0 taken 6153136 times.
✗ Branch 1 not taken.
6153136 if(ctype==cSPINTILE1)
18720 {
18721 // Awaken spinning tile
18722 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
18723 }
18724 6153136 }
18725 384571 }
18726
18727
2/2
✓ Branch 0 taken 34905 times.
✓ Branch 1 taken 56 times.
34961 if(tmpscr->enemyflags&efTRAP2)
18728 {
18729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18730 {
18731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(64, 80, centerTrapID, -14))
18732 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18733
18734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(176, 80, centerTrapID, -14))
18735 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18736 56 }
18737 56 }
18738
18739
2/2
✓ Branch 0 taken 34878 times.
✓ Branch 1 taken 83 times.
34961 if(tmpscr->enemyflags&efROCKS)
18740 {
18741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18742 {
18743 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18744 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18745 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18746 83 }
18747 83 }
18748
18749 34961 activate_fireball_statues();
18750 34961 }
18751
18752 44621178 void update_slope_combopos(int32_t lyr, int32_t pos)
18753 {
18754
2/4
✓ Branch 0 taken 44621178 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44621178 times.
44621178 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
18755 44621178 mapscr* s = FFCore.tempScreens[lyr];
18756 44621178 newcombo const& cmb = combobuf[s->data[pos]];
18757
18758 44621178 auto id = (176*lyr)+pos;
18759 44621178 auto it = slopes.find(id);
18760
18761 44621178 bool wasSlope = it!=slopes.end();
18762 44621178 bool isSlope = cmb.type == cSLOPE;
18763
18764
3/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 44620975 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203 times.
44621178 if(isSlope && !wasSlope)
18765 {
18766 203 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
18767 203 }
18768
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44620975 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44620975 else if(wasSlope && !isSlope)
18769 {
18770 slopes.erase(it);
18771 }
18772 44621178 }
18773 35336 void update_slope_comboposes()
18774 {
18775
2/2
✓ Branch 0 taken 247352 times.
✓ Branch 1 taken 35336 times.
282688 for(auto lyr = 0; lyr < 7; ++lyr)
18776 {
18777
2/2
✓ Branch 0 taken 43533952 times.
✓ Branch 1 taken 247352 times.
43781304 for(auto pos = 0; pos < 176; ++pos)
18778 43533952 update_slope_combopos(lyr,pos);
18779 247352 }
18780 35336 }
18781
18782 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18783 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
18784 1160297 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
18785 {
18786 1160297 delete_fireball_shooter(s, pos);
18787 1160297 }
18788
18789 //Placeholder in case we need it.
18790 void screen_ffc_modify_preroutine(word index)
18791 {
18792 return;
18793 }
18794
18795 // Everything that must be done after we change a screen's combo to another combo. -L
18796 1160297 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
18797 {
18798 1160297 s->valid |= mVALID;
18799 1160297 activate_fireball_statue(pos);
18800
18801
2/2
✓ Branch 0 taken 1160203 times.
✓ Branch 1 taken 94 times.
1160297 if(combobuf[s->data[pos]].type==cSPINTILE1)
18802 {
18803 // Awaken spinning tile
18804 94 awaken_spinning_tile(s,pos);
18805 94 }
18806 1160297 int32_t lyr = -1;
18807
2/2
✓ Branch 0 taken 118155 times.
✓ Branch 1 taken 1042142 times.
1160297 if(s == tmpscr) lyr = 0;
18808
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 593895 times.
666966 else for(size_t q = 0; q < 6; ++q)
18809 {
18810
2/2
✓ Branch 0 taken 45084 times.
✓ Branch 1 taken 548811 times.
593895 if(s == tmpscr2+q)
18811 {
18812 45084 lyr = q+1;
18813 45084 break;
18814 }
18815 548811 }
18816
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 1087226 times.
1160297 if(lyr > -1)
18817 1087226 update_slope_combopos(lyr,pos);
18818 1160297 }
18819
18820 8797022 void screen_ffc_modify_postroutine(word index)
18821 {
18822 8797022 ffcdata& ff = tmpscr->ffcs[index];
18823 8797022 newcombo const& cmb = combobuf[ff.data];
18824
18825 8797022 auto id = (176*7)+int32_t(index);
18826 8797022 auto it = slopes.find(id);
18827
18828 8797022 bool wasSlope = it!=slopes.end();
18829
1/2
✓ Branch 0 taken 8797022 times.
✗ Branch 1 not taken.
8797022 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffc_changer);
18830
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8797022 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8797022 if(isSlope && !wasSlope)
18831 {
18832 slopes.try_emplace(id, nullptr, &ff, id);
18833 }
18834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8797022 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8797022 else if(wasSlope && !isSlope)
18835 {
18836 slopes.erase(it);
18837 }
18838
18839 8797022 tmpscr->ffcCountMarkDirty();
18840 8797022 }
18841
18842 4404 void screen_combo_modify_pre(int32_t cid)
18843 {
18844
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18845 {
18846 30828 mapscr* t = FFCore.tempScreens[lyr];
18847
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18848 {
18849
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18850 {
18851 6601 screen_combo_modify_preroutine(t,i);
18852 6601 }
18853 5425728 }
18854 30828 }
18855 4404 }
18856 4404 void screen_combo_modify_post(int32_t cid)
18857 {
18858
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18859 {
18860 30828 mapscr* t = FFCore.tempScreens[lyr];
18861
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18862 {
18863
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18864 {
18865 6601 screen_combo_modify_postroutine(t,i);
18866 6601 }
18867 5425728 }
18868 30828 }
18869
2/2
✓ Branch 0 taken 563712 times.
✓ Branch 1 taken 4404 times.
568116 for(word ind = 0; ind < MAXFFCS; ++ind)
18870 {
18871
2/2
✓ Branch 0 taken 563462 times.
✓ Branch 1 taken 250 times.
563712 if(tmpscr->ffcs[ind].data == cid)
18872 250 screen_ffc_modify_postroutine(ind);
18873 563712 }
18874 4404 }
18875
18876 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
18877 {
18878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
18879 94 }
18880
18881
18882 // It stands for next_side_pos
18883 11436 void nsp(bool random)
18884 // moves sle_x and sle_y to the next position
18885 {
18886
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8175 times.
11436 if(random)
18887 {
18888
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18889 {
18890 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18891 1634 sle_y = (zc_oldrand()%10)*16;
18892 1634 }
18893 else
18894 {
18895 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18896 1627 sle_x = (zc_oldrand()%15)*16;
18897 }
18898
18899 3261 return;
18900 }
18901
18902
2/2
✓ Branch 0 taken 6151 times.
✓ Branch 1 taken 2024 times.
8175 if(sle_x==0)
18903 {
18904
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 179 times.
2024 if(sle_y<160)
18905 1845 sle_y+=16;
18906 else
18907 179 sle_x+=16;
18908 2024 }
18909
2/2
✓ Branch 0 taken 2581 times.
✓ Branch 1 taken 3570 times.
6151 else if(sle_y==160)
18910 {
18911
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 165 times.
2581 if(sle_x<240)
18912 2416 sle_x+=16;
18913 else
18914 165 sle_y-=16;
18915 2581 }
18916
2/2
✓ Branch 0 taken 1550 times.
✓ Branch 1 taken 2020 times.
3570 else if(sle_x==240)
18917 {
18918
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 148 times.
1550 if(sle_y>0)
18919 1402 sle_y-=16;
18920 else
18921 148 sle_x-=16;
18922 1550 }
18923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18924 {
18925
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18926 2020 sle_x-=16;
18927 else
18928 sle_y+=16;
18929 2020 }
18930 11436 }
18931
18932 2426 int32_t next_side_pos(bool random)
18933 // moves sle_x and sle_y to the next available position
18934 // returns the direction the enemy should face
18935 {
18936 bool blocked;
18937 2426 int32_t c=0;
18938
18939 2426 do
18940 {
18941
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11305 times.
11436 nsp(c>35 ? false : random);
18942
4/4
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 8992 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2425 times.
13861 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
18943
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
18944
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2425 times.
✗ Branch 3 not taken.
2425 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
18945
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2425 times.
2425 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
18946 2425 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
18947
18948
2/2
✓ Branch 0 taken 11435 times.
✓ Branch 1 taken 1 times.
11436 if(++c>50)
18949 1 return -1;
18950
2/2
✓ Branch 0 taken 9010 times.
✓ Branch 1 taken 2425 times.
11435 }
18951 11435 while(blocked);
18952
18953 2425 int32_t dir=0;
18954
18955
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 735 times.
2425 if(sle_x==0) dir=right;
18956
18957
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 569 times.
2425 if(sle_y==0) dir=down;
18958
18959
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 706 times.
2425 if(sle_x==240) dir=left;
18960
18961
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 if(sle_y==168) dir=up;
18962
18963 2425 return dir;
18964 2426 }
18965
18966 bool can_side_load(int32_t id)
18967 {
18968 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18969 {
18970 return false;
18971 }
18972 switch(guysbuf[id].family) //id&0x0FFF)
18973 {
18974 //case eTEK1:
18975 //case eTEK2:
18976 //case eTEK3:
18977 //case eLEV1:
18978 //case eLEV2:
18979 //case eLEV3:
18980 //case eRAQUAM:
18981 //case eLAQUAM:
18982 //case eDODONGO:
18983 //case eMANHAN:
18984 //case eGLEEOK1:
18985 //case eGLEEOK2:
18986 //case eGLEEOK3:
18987 //case eGLEEOK4:
18988 //case eDIG1:
18989 //case eDIG3:
18990 //case eGOHMA1:
18991 //case eGOHMA2:
18992 //case eCENT1:
18993 //case eCENT2:
18994 //case ePATRA1:
18995 //case ePATRA2:
18996 //case eGANON:
18997 //case eMANHAN2:
18998 //case eCEILINGM: later
18999 //case eFLOORM: later
19000 //case ePATRABS:
19001 //case ePATRAL2:
19002 //case ePATRAL3:
19003 //case eGLEEOK1F:
19004 //case eGLEEOK2F:
19005 //case eGLEEOK3F:
19006 //case eGLEEOK4F:
19007 //case eDODONGOBS:
19008 //case eDODONGOF:
19009 //case eGOHMA3:
19010 //case eGOHMA4:
19011 //case eSHOOTMAGIC:
19012 //case eSHOOTROCK:
19013 //case eSHOOTSPEAR:
19014 //case eSHOOTSWORD:
19015 //case eSHOOTFLAME:
19016 //case eSHOOTFLAME2:
19017 //case eSHOOTFBALL:
19018 case eeTEK:
19019 case eeLEV:
19020 case eeAQUA:
19021 case eeDONGO:
19022 case eeMANHAN:
19023 case eeGLEEOK:
19024 case eeDIG:
19025 case eeGHOMA:
19026 case eeLANM:
19027 case eePATRA:
19028 case eeGANON:
19029 case eePROJECTILE:
19030 return false;
19031 break;
19032 }
19033
19034 return true;
19035 }
19036
19037 static bool script_sle = false;
19038 static int32_t sle_pattern = 0;
19039 void script_side_load_enemies()
19040 {
19041 if(script_sle || sle_clk) return;
19042 sle_cnt = 0;
19043 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19044 ++sle_cnt;
19045 script_sle = true;
19046 sle_pattern = tmpscr->pattern;
19047 sle_clk = 0;
19048 }
19049
19050 54442 void side_load_enemies()
19051 {
19052
3/4
✓ Branch 0 taken 54442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 682 times.
54442 if(!script_sle && sle_clk==0)
19053 {
19054 682 sle_pattern = tmpscr->pattern;
19055 682 sle_cnt = 0;
19056 682 int32_t guycnt = 0;
19057 682 int16_t s = (currmap<<7)+currscr;
19058 682 bool beenhere=false;
19059 682 bool reload=true;
19060 682 bool unbeatablereload = true;
19061
19062 682 load_default_enemies();
19063
19064
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 682 times.
4774 for(int32_t i=0; i<6; i++)
19065
2/2
✓ Branch 0 taken 3889 times.
✓ Branch 1 taken 203 times.
4295 if(visited[i]==s)
19066 203 beenhere=true;
19067
19068
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 479 times.
682 if(!beenhere)
19069 {
19070 479 visited[vhead]=s;
19071 479 vhead = (vhead+1)%6;
19072 479 }
19073
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 42 times.
203 else if(game->guys[s]==0)
19074 {
19075 42 sle_cnt=0;
19076 42 reload=false;
19077 42 }
19078
19079
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 640 times.
682 if(reload)
19080 {
19081 640 sle_cnt = game->guys[s];
19082
19083
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 220 times.
640 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19084 640 || sle_cnt==0)
19085 {
19086
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 220 times.
1270 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19087 1050 ++sle_cnt;
19088 220 }
19089
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 479 times.
✗ Branch 3 not taken.
640 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19090 {
19091 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19092 {
19093 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19094 {
19095 unbeatablereload = false;
19096 }
19097 }
19098 if (unbeatablereload)
19099 {
19100 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19101 {
19102 ++sle_cnt;
19103 }
19104 }
19105 }
19106 640 }
19107
19108
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 651 times.
682 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19109 {
19110 31 sle_cnt = 0;
19111
19112
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19113 108 ++sle_cnt;
19114 31 }
19115
19116
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 682 times.
3124 for(int32_t i=0; i<sle_cnt; i++)
19117 2442 ++guycnt;
19118
19119 682 game->guys[s] = guycnt;
19120 682 }
19121
19122
2/2
✓ Branch 0 taken 52016 times.
✓ Branch 1 taken 2426 times.
54442 if((++sle_clk+8)%24 == 0)
19123 {
19124 2426 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19125
19126
4/4
✓ Branch 0 taken 2425 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 2193 times.
2426 if(dir==-1 || tooclose(sle_x,sle_y,32))
19127 {
19128 233 return;
19129 }
19130
19131 2193 int32_t enemy_slot=guys.Count();
19132
19133
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2193 times.
2193 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19134 sle_cnt--;
19135
19136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(sle_cnt > 0)
19137 {
19138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19139 {
19140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19141 {
19142 2193 guys.spr(enemy_slot)->dir = dir;
19143 2193 }
19144
1/2
✓ Branch 0 taken 2193 times.
✗ Branch 1 not taken.
2193 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19145 {
19146 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19147 {
19148 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19149 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19150 }
19151 }
19152 2193 }
19153 2193 }
19154 2193 }
19155
19156
2/2
✓ Branch 0 taken 53631 times.
✓ Branch 1 taken 578 times.
54209 if(sle_cnt<=0)
19157 {
19158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if(script_sle)
19159 script_sle = false;
19160 578 else loaded_enemies=true;
19161 578 sle_clk = 0;
19162 578 }
19163 54442 }
19164
19165 1208111 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19166 {
19167
19168
4/4
✓ Branch 0 taken 1105227 times.
✓ Branch 1 taken 102884 times.
✓ Branch 2 taken 102884 times.
✓ Branch 3 taken 1208111 times.
1208111 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19169 {
19170 205768 return false; //never 0, never OoB.
19171 }
19172 // No corner enemies
19173
6/6
✓ Branch 0 taken 1042351 times.
✓ Branch 1 taken 165760 times.
✓ Branch 2 taken 40016 times.
✓ Branch 3 taken 1082367 times.
✓ Branch 4 taken 114320 times.
✓ Branch 5 taken 91456 times.
1208111 if((x==0 || x==240) && (y==0 || y==160))
19174
19175 205776 return false;
19176
19177 //Is a no spawn combo...
19178
4/4
✓ Branch 0 taken 1082355 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1082359 times.
1082367 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19179 16 return false;
19180
19181 // No enemies in dungeon walls
19182
10/10
✓ Branch 0 taken 655073 times.
✓ Branch 1 taken 427286 times.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 509953 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 422881 times.
✓ Branch 7 taken 87072 times.
✓ Branch 8 taken 87072 times.
✓ Branch 9 taken 335809 times.
1082359 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19183 319264 return false;
19184
19185 // Too close
19186
4/4
✓ Branch 0 taken 74233 times.
✓ Branch 1 taken 688862 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 74132 times.
763095 if(tooclose(x,y,40) && t<11)
19187 74132 return false;
19188
19189 // Can't fly onto it?
19190
4/4
✓ Branch 0 taken 122271 times.
✓ Branch 1 taken 566692 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 17932 times.
742855 if(isflier(tmpscr->enemy[i])&&
19191
2/2
✓ Branch 0 taken 121881 times.
✓ Branch 1 taken 390 times.
122271 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19192
2/2
✓ Branch 0 taken 53892 times.
✓ Branch 1 taken 67989 times.
121881 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19193 18322 return false;
19194
19195 // Can't jump onto it?
19196 if
19197 (
19198
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 86588 times.
757233 guysbuf[tmpscr->enemy[i]].family==eeTEK
19199
19200
2/2
✓ Branch 0 taken 86606 times.
✓ Branch 1 taken 584035 times.
670641 &&
19201 (
19202
2/2
✓ Branch 0 taken 86599 times.
✓ Branch 1 taken 7 times.
86606 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19203
2/2
✓ Branch 0 taken 86598 times.
✓ Branch 1 taken 1 times.
86599 COMBOTYPE(x+8,y+8)==cNOENEMY||
19204
1/2
✓ Branch 0 taken 86598 times.
✗ Branch 1 not taken.
86598 ispitfall(x+8,y+8)||
19205
2/2
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 6 times.
86598 MAPFLAG(x+8,y+8)==mfNOENEMY||
19206 86592 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19207 )
19208 )
19209 {
19210 18 return false;
19211 }
19212
19213 // Other off-limit combos
19214
6/6
✓ Branch 0 taken 566670 times.
✓ Branch 1 taken 103953 times.
✓ Branch 2 taken 480082 times.
✓ Branch 3 taken 86588 times.
✓ Branch 4 taken 263616 times.
✓ Branch 5 taken 216466 times.
1150705 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19215
2/2
✓ Branch 0 taken 268958 times.
✓ Branch 1 taken 211124 times.
480082 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19216 480082 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19217 216466 return false;
19218
19219 // Don't ever generate enemies on these combos!
19220
4/4
✓ Branch 0 taken 453853 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 453859 times.
454157 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19221 310 return false;
19222
19223 //BS Dodongos need at least 2 spaces.
19224
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 452820 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
453859 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].attributes[9] ==1))
19225 {
19226
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19227
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19228
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19229 ((y>144)||_walkflag(x, y+24,2)))
19230 {
19231 return false;
19232 }
19233 19 }
19234
19235 453853 return true;
19236 1105227 }
19237
19238 159462 bool is_ceiling_pattern(int32_t i)
19239 {
19240
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 159442 times.
159462 return (i==pCEILING || i==pCEILINGR);
19241 }
19242
19243 5716 int32_t placeenemy(int32_t i)
19244 {
19245 5716 std::map<int32_t, int32_t> freeposcache;
19246 5716 int32_t frees = 0;
19247
19248
2/2
✓ Branch 0 taken 62876 times.
✓ Branch 1 taken 5716 times.
68592 for(int32_t y=0; y<176; y+=16)
19249 {
19250
2/2
✓ Branch 0 taken 1006016 times.
✓ Branch 1 taken 62876 times.
1068892 for(int32_t x=0; x<256; x+=16)
19251 {
19252
3/4
✓ Branch 0 taken 1006016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396120 times.
✓ Branch 3 taken 609896 times.
1006016 if(is_starting_pos(i,x,y,0))
19253 {
19254
1/2
✓ Branch 0 taken 396120 times.
✗ Branch 1 not taken.
396120 freeposcache[frees++] = (y&0xF0)+(x>>4);
19255 396120 }
19256 1006016 }
19257 62876 }
19258
19259
2/2
✓ Branch 0 taken 5705 times.
✓ Branch 1 taken 11 times.
5716 if(frees > 0)
19260
2/4
✓ Branch 0 taken 5705 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5705 times.
✗ Branch 3 not taken.
5705 return freeposcache[zc_oldrand()%frees];
19261
19262 11 return -1;
19263 5716 }
19264
19265 80542 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19266 {
19267 80542 bool placed=false;
19268 80542 int32_t t=-1;
19269
19270 // First: enemy combo flags
19271
2/2
✓ Branch 0 taken 800202 times.
✓ Branch 1 taken 63449 times.
863651 for(int32_t sy=0; sy<176; sy+=16)
19272 {
19273
2/2
✓ Branch 0 taken 12675979 times.
✓ Branch 1 taken 783109 times.
13459088 for(int32_t sx=0; sx<256; sx+=16)
19274 {
19275 12675979 int32_t cflag = MAPFLAG(sx, sy);
19276 12675979 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19277
19278
2/4
✓ Branch 0 taken 12675979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12675979 times.
✗ Branch 3 not taken.
12675979 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19279 {
19280 if(!ok2add(tmpscr->enemy[i]))
19281 {
19282 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19283 }
19284 else
19285 {
19286 addenemy(sx,
19287 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19288 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19289
19290 ++guycnt;
19291
19292 placed=true;
19293 goto placed_enemy;
19294 }
19295 }
19296
19297
4/4
✓ Branch 0 taken 12658837 times.
✓ Branch 1 taken 17142 times.
✓ Branch 2 taken 12658837 times.
✓ Branch 3 taken 17142 times.
12675979 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19298 {
19299
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17093 times.
17142 if(!ok2add(tmpscr->enemy[i]))
19300 {
19301
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19302 49 }
19303 else
19304 {
19305 34186 addenemy(sx,
19306
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17093 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19307
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17093 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19308
19309 17093 ++guycnt;
19310
19311 17093 placed=true;
19312 17093 goto placed_enemy;
19313 }
19314 49 }
19315 12658886 }
19316 783109 }
19317
19318 // Next: enemy pattern
19319
6/8
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 58510 times.
✓ Branch 2 taken 57954 times.
✓ Branch 3 taken 5495 times.
✓ Branch 4 taken 57954 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57954 times.
63449 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19320 {
19321 57954 do
19322 {
19323
19324 // NES positions
19325 99432 pos%=9;
19326 99432 x=stx[loadside][pos];
19327 99432 y=sty[loadside][pos];
19328 99432 ++pos;
19329 99432 ++t;
19330
2/2
✓ Branch 0 taken 41478 times.
✓ Branch 1 taken 57954 times.
157386 }
19331
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99211 times.
99432 while((t< 20) && !is_starting_pos(i,x,y,t));
19332 57954 }
19333
19334
4/4
✓ Branch 0 taken 57954 times.
✓ Branch 1 taken 5495 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57733 times.
63449 if(t<0 || t >= 20) // above enemy pattern failed
19335 {
19336 // Final chance: find a random position anywhere onscreen
19337 5716 int32_t randpos = placeenemy(i);
19338
19339
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5705 times.
5716 if(randpos>-1)
19340 {
19341 5705 x=(randpos&15)<<4;
19342 5705 y= randpos&0xF0;
19343 5705 }
19344 else // All opportunities failed - abort
19345 {
19346 11 return;
19347 }
19348 5705 }
19349
19350 {
19351 63438 int32_t c=0;
19352 63438 c=clk;
19353
19354
2/2
✓ Branch 0 taken 9584 times.
✓ Branch 1 taken 53854 times.
63438 if(!slowguy(tmpscr->enemy[i]))
19355 53854 ++fastguys;
19356
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 7998 times.
9584 else if(fastguys>0)
19357 1586 c=-15*(i-fastguys+2);
19358 else
19359 7998 c=-15*(i+1);
19360
19361
4/6
✓ Branch 0 taken 28861 times.
✓ Branch 1 taken 34577 times.
✓ Branch 2 taken 28861 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28861 times.
63438 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19362 {
19363 // Special case for blue leevers
19364
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 26967 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
28861 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].attributes[0]==1)
19365 761 c=-15*(i+1);
19366 else
19367 28100 c=-15;
19368 28861 }
19369
19370
2/2
✓ Branch 0 taken 62638 times.
✓ Branch 1 taken 800 times.
63438 if(!ok2add(tmpscr->enemy[i]))
19371 {
19372
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19373 800 }
19374 else
19375 {
19376
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62638 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19377 {
19378
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62508 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
125276 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19379
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
62638 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19380
19381 62638 ++guycnt;
19382 62638 }
19383 }
19384
19385 63438 placed=true;
19386 63438 } // if(t < 20)
19387
19388 placed_enemy:
19389
19390 // I don't like this, but it seems to work...
19391 static bool foundCarrier;
19392
19393
2/2
✓ Branch 0 taken 59157 times.
✓ Branch 1 taken 21374 times.
80531 if(i==0)
19394 21374 foundCarrier=false;
19395
19396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80531 times.
80531 if(placed)
19397 {
19398
4/4
✓ Branch 0 taken 21374 times.
✓ Branch 1 taken 59157 times.
✓ Branch 2 taken 21205 times.
✓ Branch 3 taken 169 times.
80531 if(i==0 && tmpscr->enemyflags&efLEADER)
19399 {
19400 169 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19401
19402
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if(index!=-1)
19403 {
19404 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(index!=-1)
19407 {
19408 162 ((enemy*)guys.spr(index))->leader = true;
19409 162 }
19410 162 }
19411 169 }
19412
19413
4/4
✓ Branch 0 taken 80308 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 80244 times.
✓ Branch 3 taken 64 times.
80531 if(!foundCarrier && hasitem&(4|2))
19414 {
19415 64 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19416
19417
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesnt_count)==0)
19418 {
19419 64 ((enemy*)guys.spr(index))->itemguy = true;
19420 64 foundCarrier=true;
19421 64 }
19422 64 }
19423 80531 }
19424 80542 }
19425
19426 bool scriptloadenemies()
19427 {
19428 loaded_enemies = true;
19429 if(script_sle || sle_clk) return false;
19430 if(tmpscr->pattern==pNOSPAWN) return false;
19431
19432 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19433 {
19434 script_side_load_enemies();
19435 return true;
19436 }
19437
19438 int32_t pos=zc_oldrand()%9;
19439 int32_t clk=-15,x=0,y=0,fastguys=0;
19440 int32_t i=0,guycnt=0;
19441 int32_t loadcnt = 10;
19442
19443 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19444 {
19445 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19446 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19447 if (guys.Count() > preguycount)
19448 {
19449 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19450 {
19451 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19452 {
19453 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19454 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19455 }
19456 }
19457 }
19458 --clk;
19459 }
19460 return true;
19461 }
19462
19463 14130987 void loadenemies()
19464 {
19465
3/4
✓ Branch 0 taken 14130987 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 14077227 times.
14130987 if(script_sle || sle_clk)
19466 {
19467 53760 side_load_enemies();
19468 53760 return;
19469 }
19470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14077227 times.
14077227 if(tmpscr->pattern==pNOSPAWN) return;
19471
2/2
✓ Branch 0 taken 14042176 times.
✓ Branch 1 taken 35051 times.
14077227 if(loaded_enemies)
19472 14042176 return;
19473
19474 // check if it's the dungeon boss and it has been beaten before
19475
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34692 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
35051 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
19476 {
19477 90 loaded_enemies = true;
19478 90 return;
19479 }
19480
19481
4/4
✓ Branch 0 taken 34520 times.
✓ Branch 1 taken 441 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 34279 times.
34961 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19482 {
19483 682 side_load_enemies();
19484 682 return;
19485 }
19486
19487 34279 loaded_enemies=true;
19488
19489 // do enemies that are always loaded
19490 34279 load_default_enemies();
19491
19492 // dungeon basements
19493
19494 static byte dngn_enemy_x[4] = {32,96,144,208};
19495
19496
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 33375 times.
34279 if(currscr>=128)
19497 {
19498
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 if(DMaps[currdmap].flags&dmfCAVES) return;
19499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
19500 {
19501 for(int32_t i=0; i<10; i++)
19502 {
19503 if ( tmpscr->enemy[i] )
19504 {
19505 int32_t preguycount = guys.Count();
19506 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
19507 if (guys.Count() > preguycount)
19508 {
19509 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19510 {
19511 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19512 {
19513 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19514 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19515 }
19516 }
19517 }
19518 }
19519 }
19520 }
19521 else
19522 {
19523
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19524 {
19525 1900 int32_t preguycount = guys.Count();
19526
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
19527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19528 {
19529
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19530 {
19531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19532 {
19533 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19534 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19535 4 }
19536 4 }
19537 1900 }
19538 1900 }
19539 }
19540 475 return;
19541 }
19542
19543 // check if it's been long enough to reload all enemies
19544
19545 33375 int32_t loadcnt = 10;
19546 33375 int16_t s = (currmap<<7)+currscr;
19547 33375 bool beenhere = false;
19548 33375 bool reload = true;
19549 33375 bool unbeatablereload = true;
19550
19551
2/2
✓ Branch 0 taken 200250 times.
✓ Branch 1 taken 33375 times.
233625 for(int32_t i=0; i<6; i++)
19552
2/2
✓ Branch 0 taken 191071 times.
✓ Branch 1 taken 9179 times.
209429 if(visited[i]==s)
19553 9179 beenhere = true;
19554
19555
2/2
✓ Branch 0 taken 9179 times.
✓ Branch 1 taken 24196 times.
33375 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19556 {
19557 24196 visited[vhead]=s; //If not, it adds it to the array,
19558 24196 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
19559 24196 }
19560
2/2
✓ Branch 0 taken 4611 times.
✓ Branch 1 taken 4568 times.
9179 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19561 {
19562 4568 loadcnt = 0; //It will tell it not to load any enemies,
19563 4568 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19564 4568 }
19565
19566
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 28807 times.
33375 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19567 {
19568 28807 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19569
19570
2/4
✓ Branch 0 taken 10143 times.
✓ Branch 1 taken 18664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28807 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10143 times.
10143 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19572 18664 loadcnt = 10; //That means all enemies need to be respawned.
19573
3/4
✓ Branch 0 taken 24196 times.
✓ Branch 1 taken 4611 times.
✓ Branch 2 taken 24196 times.
✗ Branch 3 not taken.
28807 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19574 {
19575 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
19576 {
19577 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19578 {
19579 unbeatablereload = false;
19580 }
19581 }
19582 if (unbeatablereload)
19583 {
19584 loadcnt = 10;
19585 }
19586 }
19587 28807 }
19588
19589
4/4
✓ Branch 0 taken 31916 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 31729 times.
33375 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19590 1646 loadcnt = 10; //All enemies also need to be respawned.
19591
19592 33375 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19593 33375 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
19594 33375 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19595
19596
4/4
✓ Branch 0 taken 14568 times.
✓ Branch 1 taken 99349 times.
✓ Branch 2 taken 80542 times.
✓ Branch 3 taken 33375 times.
113917 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19597 {
19598 80542 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19599 80542 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19600
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 79731 times.
80542 if (guys.Count() > preguycount)
19601 {
19602
2/2
✓ Branch 0 taken 77384 times.
✓ Branch 1 taken 2347 times.
79731 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19603 {
19604
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2343 times.
2347 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19605 {
19606 2343 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19607 2343 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19608 2343 }
19609 2347 }
19610 79731 }
19611
19612 80542 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19613 80542 }
19614
19615 33375 game->guys[s] = guycnt;
19616 //} //if(true)
19617 14130987 }
19618 233 void moneysign()
19619 {
19620 233 additem(48,108,iRupy,ipDUMMY);
19621 233 set_clip_state(pricesdisplaybuf, 0);
19622 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19623 233 }
19624
19625 3252 void putprices(bool sign)
19626 {
19627
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3223 times.
3252 if(fadeclk > 0) return;
19628
19629 3223 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19630 3223 int32_t step=32;
19631 3223 int32_t x=80;
19632
19633
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2942 times.
3223 if(prices[2]==0)
19634 {
19635 2942 step<<=1;
19636
19637
2/2
✓ Branch 0 taken 2910 times.
✓ Branch 1 taken 32 times.
2942 if(prices[1]==0)
19638 {
19639 2910 x=112;
19640 2910 }
19641 2942 }
19642
19643
2/2
✓ Branch 0 taken 3223 times.
✓ Branch 1 taken 9669 times.
12892 for(int32_t i=0; i<3; i++)
19644 {
19645 // Kind of stupid, but it works: 100000 is used to indicate that an item
19646 // has a price of zero rather than there being no item.
19647 // 100000 isn't a valid price, so this doesn't cause problems.
19648
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9669 if(prices[i]!=0 && prices[i]<100000)
19649 {
19650 char buf[8];
19651 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19652
19653 1039 int32_t l=(int32_t)strlen(buf);
19654 1039 set_clip_state(pricesdisplaybuf, 0);
19655
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19656 1039 }
19657
19658 9669 x+=step;
19659 9669 }
19660 3252 }
19661
19662 // Setting up special rooms
19663 // Also called when the Letter is used successfully.
19664 1202 void setupscreen()
19665 {
19666 1202 boughtsomething=false;
19667 1202 int32_t t=currscr<128?0:1;
19668 1202 word str=tmpscr[t].str;
19669
19670 // Prices are already set to 0 in dowarp()
19671
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1202 switch(tmpscr[t].room)
19672 {
19673 case rSP_ITEM: // special item
19674 161 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19675 161 break;
19676
19677 case rINFO: // pay for info
19678 {
19679 28 int32_t count = 0;
19680 28 int32_t base = 88;
19681 28 int32_t step = 5;
19682
19683 28 moneysign();
19684
19685
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19686 {
19687
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[tmpscr[t].catchall].str[i])
19688 {
19689 84 ++count;
19690 84 }
19691 else
19692 break;
19693 84 }
19694
19695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19696 {
19697
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19698 {
19699 base = 88+32;
19700 }
19701
19702
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19703 {
19704 step = 6;
19705 }
19706
19707
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19708 {
19709 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19710 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19711 84 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
19712
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19713 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19714 84 int32_t itemid = current_item_id(itype_wealthmedal);
19715
19716
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19717 {
19718 if(itemsbuf[itemid].flags & item_flag1)
19719 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19720 else
19721 prices[i]-=itemsbuf[itemid].misc1;
19722 prices[i]=vbound(prices[i], -99999, 0);
19723 if(prices[i]==0)
19724 prices[i]=100000;
19725 }
19726
19727
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19728 prices[i]=-1;
19729 84 }
19730 28 }
19731
19732 28 break;
19733 }
19734
19735 case rMONEY: // secret money
19736 44 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19737 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19738 44 break;
19739
19740 case rGAMBLE: // gambling
19741 11 prices[0]=prices[1]=prices[2]=-10;
19742 11 moneysign();
19743 11 additem(88,89,iRupy,ipMONEY+ipDUMMY);
19744 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19745 11 additem(120,89,iRupy,ipMONEY+ipDUMMY);
19746 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19747 11 additem(152,89,iRupy,ipMONEY+ipDUMMY);
19748 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19749 11 break;
19750
19751 case rREPAIR: // door repair
19752
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19753 // }
19754 13 repaircharge=tmpscr[t].catchall;
19755 13 break;
19756
19757 case rMUPGRADE: // upgrade magic
19758 2 adjustmagic=true;
19759 2 break;
19760
19761 case rLEARNSLASH: // learn slash attack
19762 2 learnslash=true;
19763 2 break;
19764
19765 case rRP_HC: // heart container or red potion
19766 17 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19767 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19768 17 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19769 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19770 17 break;
19771
19772 case rP_SHOP: // potion shop
19773
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19774 {
19775 12 str=0;
19776 12 break;
19777 }
19778
19779 [[fallthrough]];
19780 case rTAKEONE: // take one
19781 case rSHOP: // shop
19782 {
19783 194 int32_t count = 0;
19784 194 int32_t base = 88;
19785 194 int32_t step = 5;
19786
19787
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(tmpscr[t].room != rTAKEONE)
19788 193 moneysign();
19789
19790 //count and align the stuff
19791
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19792 {
19793
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
19794 {
19795 523 ++count;
19796 523 }
19797 else
19798 {
19799 37 break;
19800 }
19801 523 }
19802
19803
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19804 {
19805 22 base = 88+32;
19806 22 }
19807
19808
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19809 {
19810 15 step = 6;
19811 15 }
19812
19813
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19814 {
19815 523 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
19816 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19817
19818
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(tmpscr[t].room != rTAKEONE)
19819 {
19820 521 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
19821
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19822 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19823 521 int32_t itemid = current_item_id(itype_wealthmedal);
19824
19825
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19826 {
19827
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19828 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19829 else
19830 prices[i]+=itemsbuf[itemid].misc1;
19831 9 prices[i]=vbound(prices[i], 0, 99999);
19832
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19833 prices[i]=100000;
19834 9 }
19835
19836
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
19837 prices[i]=1;
19838 521 }
19839 523 }
19840
19841 194 break;
19842 }
19843 case rBOTTLESHOP: // bottle shop
19844 {
19845 1 int32_t count = 0;
19846 1 int32_t base = 88;
19847 1 int32_t step = 5;
19848
19849 1 moneysign();
19850 1 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
19851 //count and align the stuff
19852
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19853 {
19854
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19855 {
19856 3 ++count;
19857 3 }
19858 else
19859 {
19860 break;
19861 }
19862 3 }
19863
19864
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19865 {
19866 base = 88+32;
19867 }
19868
19869
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19870 {
19871 step = 6;
19872 }
19873
19874
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19875 {
19876 3 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19877 //{ Setup dummy item
19878 3 item* curItem = ((item*)items.spr(items.Count()-1));
19879 3 curItem->PriceIndex = i;
19880 3 newcombo const& cmb = combobuf[bst.comb[i]];
19881 3 curItem->o_tile = cmb.o_tile;
19882 3 curItem->o_cset = bst.cset[i];
19883 3 curItem->cs = curItem->o_cset;
19884 3 curItem->tile = cmb.o_tile;
19885 3 curItem->o_speed = cmb.speed;
19886 3 curItem->o_delay = 0;
19887 3 curItem->frames = cmb.frames;
19888 3 curItem->flip = cmb.flip;
19889 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19890 3 curItem->pstring = 0;
19891 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19892 3 curItem->flash = false;
19893 3 curItem->twohand = false;
19894 3 curItem->anim = true;
19895 3 curItem->hit_width=1;
19896 3 curItem->hyofs=4;
19897 3 curItem->hit_height=12;
19898 3 curItem->script=0;
19899 3 curItem->txsz=1;
19900 3 curItem->tysz=1;
19901 //}
19902
19903 3 prices[i] = bst.price[i];
19904
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19905 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19906 3 int32_t itemid = current_item_id(itype_wealthmedal);
19907
19908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19909 {
19910 if(itemsbuf[itemid].flags & item_flag1)
19911 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19912 else
19913 prices[i]+=itemsbuf[itemid].misc1;
19914 prices[i]=vbound(prices[i], 0, 99999);
19915 if(prices[i]==0)
19916 prices[i]=100000;
19917 }
19918
19919
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19920 prices[i]=1;
19921 3 }
19922
19923 1 break;
19924 }
19925
19926 case rBOMBS: // more bombs
19927 19 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19928 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19929 19 prices[0]=-tmpscr[t].catchall;
19930 19 break;
19931
19932 case rARROWS: // more arrows
19933 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19934 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19935 prices[0]=-tmpscr[t].catchall;
19936 break;
19937
19938 case rSWINDLE: // leave heart container or money
19939 14 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
19940 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19941 14 prices[0]=-1;
19942 14 additem(152,89,iRupy,ipDUMMY+ipMONEY);
19943 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19944 14 prices[1]=-tmpscr[t].catchall;
19945 14 break;
19946
19947 }
19948
19949
3/4
✓ Branch 0 taken 1183 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1183 times.
1202 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
19950 {
19951 19 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
19952 19 int32_t itemid = current_item_id(itype_wealthmedal);
19953
19954
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19955 {
19956 if(itemsbuf[itemid].flags & item_flag1)
19957 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19958 else
19959 prices[i]+=itemsbuf[itemid].misc1;
19960 }
19961
19962
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(tmpscr[t].catchall>1 && prices[i]>-1)
19963 prices[i]=-1;
19964 19 }
19965
19966 1202 putprices(false);
19967
19968
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 60 times.
1202 if(str)
19969 {
19970 1142 donewmsg(str);
19971 1142 }
19972 else
19973 {
19974 60 Hero.unfreeze();
19975 }
19976 1202 }
19977
19978 // Increments msgptr and returns the control code argument pointed at.
19979 3409 word grab_next_argument()
19980 {
19981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3409 times.
3409 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
19982 3409 byte val=MsgStrings[msgstr].s[++msgptr]-1;
19983 3409 word ret=val;
19984
19985 // If an argument is succeeded by 255, then it's a three-byte argument -
19986 // between 254 and 65535 (or whatever the maximum actually is)
19987
2/2
✓ Branch 0 taken 3285 times.
✓ Branch 1 taken 109 times.
3409 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
19988
2/2
✓ Branch 0 taken 3394 times.
✓ Branch 1 taken 15 times.
3409 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
19989 {
19990 109 val=MsgStrings[msgstr].s[msgptr+2];
19991 109 word next=val;
19992 109 ret += 254*next;
19993 109 msgptr+=2;
19994 109 }
19995
19996 3409 return ret;
19997 3409 }
19998
19999 enum
20000 {
20001 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20002 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20003
20004 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20005
20006 MNU_DATA_MAX
20007 };
20008 struct menu_choice
20009 {
20010 int32_t x, y;
20011 int32_t pos;
20012 int32_t upos, dpos, lpos, rpos;
20013 8 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20014 8 {}
20015 8 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20016 int32_t dpos, int32_t lpos, int32_t rpos)
20017 8 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20018 8 {}
20019 };
20020 static int32_t msg_menu_data[MNU_DATA_MAX];
20021 static bool do_run_menu = false;
20022 bool do_end_str = false;
20023 static bool wait_advance = false;
20024 356 static std::map<int32_t, menu_choice> menu_options;
20025 43107 void clr_msg_data()
20026 {
20027 43107 do_end_str = false;
20028 43107 wait_advance = false;
20029 43107 do_run_menu = false;
20030 43107 menu_options.clear();
20031 43107 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20032 43107 }
20033
20034 static bool doing_name_insert = false;
20035 static char namebuf[9] = {0};
20036 static char* nameptr = NULL;
20037 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20038 965 bool runMenuCursor()
20039 {
20040 965 clear_bitmap(msg_menu_bmp_buf);
20041
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!menu_options.size())
20042 {
20043 msg_menu_data[MNU_CHOSEN] = 0;
20044 return true; //end menu
20045 }
20046 965 int32_t pos = msg_menu_data[MNU_CHOSEN];
20047 //If the cursor is at an invalid pos, find the first pos >= 0...
20048
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20049 {
20050 pos = 0;
20051 while(menu_options.find(pos) == menu_options.end())
20052 ++pos;
20053 }
20054 965 menu_choice* ch = &menu_options[pos];
20055
20056 965 bool pressed = true;
20057
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 964 times.
965 if(rUp()) pos = ch->upos;
20058
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 962 times.
964 else if(rDown()) pos = ch->dpos;
20059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rLeft()) pos = ch->lpos;
20060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rRight()) pos = ch->rpos;
20061 962 else pressed = false;
20062
20063
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
965 if(pressed)
20064 3 msg_menu_data[MNU_TIMER] = 1;
20065
20066 965 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20067 965 bool held = false;
20068
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 48 times.
965 if(hold_input)
20069 {
20070 48 held = true;
20071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(Up()) pos = ch->upos;
20072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Down()) pos = ch->dpos;
20073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Left()) pos = ch->lpos;
20074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Right()) pos = ch->rpos;
20075 48 else held = false;
20076 48 }
20077 //If the cursor is at an invalid pos, find the first pos >= 0...
20078
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20079 {
20080 pos = 0;
20081 while(menu_options.find(pos) == menu_options.end())
20082 ++pos;
20083 }
20084
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 3 times.
965 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20085 3 sfx(MsgStrings[msgstr].sfx);
20086
20087 965 ch = &menu_options[pos];
20088 1930 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20089 965 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20090 965 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20091 965 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20092
20093 965 msg_menu_data[MNU_CHOSEN] = pos;
20094
20095
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 24 times.
965 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20096 {
20097 24 rAbtn(); //Eat
20098
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20099 24 }
20100
20101
3/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 962 times.
965 bool ret = (pressed || held) ? false : rAbtn();
20102 //Eat inputs
20103 965 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20104
20105
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 2 times.
965 if(ret)
20106 2 menu_options.clear();
20107
20108 965 return ret;
20109 //false if pos changed this frame; no confirming while moving the cursor!
20110 965 }
20111
20112 673819 bool bottom_margin_clip()
20113 {
20114 709016 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20115
2/2
✓ Branch 0 taken 638622 times.
✓ Branch 1 taken 35197 times.
673819 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20116 }
20117
20118 void update_msgstr();
20119 242981 bool parsemsgcode()
20120 {
20121
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 240294 times.
242981 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20122 240294 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20123
18/39
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 237259 times.
✓ Branch 2 taken 1276 times.
✓ Branch 3 taken 1463 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 68 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 122 times.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 8 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 4 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
240294 switch(c)
20124 {
20125 case MSGC_NEWLINE:
20126 {
20127 1276 ssc_tile_hei = ssc_tile_hei_buf;
20128
1/2
✓ Branch 0 taken 1276 times.
✗ Branch 1 not taken.
1276 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20129 1276 ssc_tile_hei_buf = -1;
20130 1276 cursor_y += thei + MsgStrings[msgstr].vspace;
20131 1276 cursor_x=msg_margins[left];
20132 1276 return true;
20133 }
20134
20135 case MSGC_COLOUR:
20136 {
20137 1463 int32_t cset = (grab_next_argument());
20138 1463 msgcolour = CSET(cset)+(grab_next_argument());
20139 1463 return true;
20140 }
20141
20142 case MSGC_SHDCOLOR:
20143 {
20144 int32_t cset = (grab_next_argument());
20145 msg_shdcol = CSET(cset)+(grab_next_argument());
20146 return true;
20147 }
20148 case MSGC_SHDTYPE:
20149 {
20150 msg_shdtype = grab_next_argument();
20151 return true;
20152 }
20153
20154 case MSGC_SPEED:
20155 {
20156 33 msgspeed=grab_next_argument();
20157 33 return true;
20158 }
20159
20160 case MSGC_CTRUP:
20161 {
20162 int32_t a1 = grab_next_argument();
20163 int32_t a2 = grab_next_argument();
20164 game->change_counter(a2, a1);
20165 return true;
20166 }
20167
20168 case MSGC_CTRDN:
20169 {
20170 2 int32_t a1 = grab_next_argument();
20171 2 int32_t a2 = grab_next_argument();
20172 2 game->change_counter(-a2, a1);
20173 2 return true;
20174 }
20175
20176 case MSGC_CTRSET:
20177 {
20178 int32_t a1 = grab_next_argument();
20179 int32_t a2 = grab_next_argument();
20180 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20181 return true;
20182 }
20183
20184 case MSGC_CTRUPPC:
20185 case MSGC_CTRDNPC:
20186 case MSGC_CTRSETPC:
20187 {
20188 2 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20189 2 int32_t counter = grab_next_argument();
20190 2 int32_t amount = grab_next_argument();
20191 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20192
20193
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(code==MSGC_CTRDNPC)
20194 amount*=-1;
20195
20196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(code==MSGC_CTRSETPC)
20197 game->set_counter(amount, counter);
20198 else
20199 2 game->change_counter(amount, counter);
20200
20201 2 return true;
20202 }
20203
20204 case MSGC_GIVEITEM:
20205 {
20206 68 int32_t itemID = grab_next_argument();
20207
20208 68 getitem(itemID, true);
20209
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20210 {
20211 68 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20212 68 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20213 68 }
20214 68 return true;
20215 }
20216
20217
20218 case MSGC_WARP:
20219 {
20220 int32_t dmap = grab_next_argument();
20221 int32_t scrn = grab_next_argument();
20222 int32_t dx = grab_next_argument();
20223 int32_t dy = grab_next_argument();
20224 int32_t wfx = grab_next_argument();
20225 int32_t sfx = grab_next_argument();
20226 if(dx >= MAX_SCC_ARG) dx = -1;
20227 if(dy >= MAX_SCC_ARG) dy = -1;
20228 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20229 do_end_str = true;
20230 return true;
20231 }
20232
20233 case MSGC_SETSCREEND:
20234 {
20235 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20236 int32_t screen = grab_next_argument();
20237 int32_t reg = grab_next_argument();
20238 int32_t val = grab_next_argument();
20239 FFCore.set_screen_d(screen + dmap, reg, val);
20240 return true;
20241 }
20242 case MSGC_TAKEITEM:
20243 {
20244 9 int32_t itemID = grab_next_argument();
20245
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( FFCore.doscript(ScriptType::Item, itemID) )
20246 {
20247 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20248 }
20249 9 takeitem(itemID);
20250
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_bwpn == itemID )
20251 {
20252 game->forced_bwpn = -1;
20253 } //not else if! -Z
20254
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_awpn == itemID )
20255 {
20256 game->forced_awpn = -1;
20257 }
20258
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_xwpn == itemID )
20259 {
20260 game->forced_xwpn = -1;
20261 } //not else if! -Z
20262
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_ywpn == itemID )
20263 {
20264 game->forced_ywpn = -1;
20265 }
20266 9 verifyBothWeapons();
20267 9 return true;
20268 }
20269
20270 case MSGC_SFX:
20271 {
20272 17 sfx((int32_t)grab_next_argument(),128);
20273 17 return true;
20274 }
20275
20276 case MSGC_MIDI:
20277 {
20278 7 int32_t music = (int32_t)(grab_next_argument());
20279
20280
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20281 1 music_stop();
20282 else
20283 6 jukebox(music+(ZC_MIDI_COUNT-1));
20284
20285 7 return true;
20286 }
20287
20288 case MSGC_NAME:
20289 {
20290 6 doing_name_insert = true;
20291 6 sprintf(namebuf, "%s", game->get_name());
20292 6 nameptr = namebuf;
20293 6 return true;
20294 }
20295
20296 case MSGC_FONT:
20297 {
20298 int fontid = grab_next_argument();
20299 int oh = text_height(msgfont);
20300 msgfont = get_zc_font(fontid);
20301 int nh = text_height(msgfont);
20302 int mh = std::max(oh,nh);
20303 if(mh > ssc_tile_hei_buf)
20304 ssc_tile_hei_buf = mh;
20305 return true;
20306 }
20307 case MSGC_RUN_FRZ_GENSCR:
20308 {
20309 word scr_id = grab_next_argument();
20310 bool force_redraw = grab_next_argument()!=0;
20311 if(force_redraw)
20312 {
20313 update_msgstr();
20314 draw_screen(tmpscr);
20315 }
20316 FFCore.runGenericFrozenEngine(scr_id);
20317 return true;
20318 }
20319 case MSGC_DRAWTILE:
20320 {
20321 int32_t tl = grab_next_argument();
20322 int32_t cs = grab_next_argument();
20323 int32_t t_wid = grab_next_argument();
20324 int32_t t_hei = grab_next_argument();
20325 int32_t fl = grab_next_argument();
20326
20327 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20328 {
20329 ssc_tile_hei = ssc_tile_hei_buf;
20330 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20331 ssc_tile_hei_buf = -1;
20332 cursor_y += thei + MsgStrings[msgstr].vspace;
20333 if(bottom_margin_clip()) return true;
20334 cursor_x=msg_margins[left];
20335 }
20336
20337 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20338 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20339 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20340 return true;
20341 }
20342
20343 case MSGC_GOTOIFRAND:
20344 {
20345 int32_t odds = (int32_t)(grab_next_argument());
20346
20347 if(!odds || !(zc_oldrand()%odds))
20348 goto switched;
20349
20350 (void)grab_next_argument();
20351 return true;
20352 }
20353
20354 case MSGC_GOTOIFGLOBAL:
20355 {
20356 int32_t arg = (int32_t)grab_next_argument();
20357 int32_t d = zc_min(7,arg);
20358 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20359 arg = (int32_t)grab_next_argument();
20360
20361 if(game->screen_d[s][d] >= arg)
20362 goto switched;
20363
20364 (void)grab_next_argument();
20365 return true;
20366 }
20367
20368 case MSGC_CHANGEPORTRAIT:
20369 {
20370 return true; //not implemented
20371 }
20372
20373 case MSGC_GOTOIFCREEND:
20374 {
20375 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20376 int32_t screen = grab_next_argument();
20377 int32_t reg = grab_next_argument();
20378 int32_t val = grab_next_argument();
20379 //int32_t nxtstr = grab_next_argument();
20380 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20381 {
20382 goto switched;
20383 }
20384 (void)grab_next_argument();
20385 return true;
20386 }
20387
20388 case MSGC_GOTOIF:
20389 {
20390 122 int32_t it = (int32_t)grab_next_argument();
20391
20392
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20393 35 goto switched;
20394
20395 87 (void)grab_next_argument();
20396 87 return true;
20397 }
20398
20399 case MSGC_GOTOIFCTR:
20400 {
20401
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20402 7 goto switched;
20403
20404 6 (void)grab_next_argument();
20405 6 return true;
20406 }
20407
20408 case MSGC_GOTOIFCTRPC:
20409 {
20410 int32_t counter = grab_next_argument();
20411 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20412
20413 if(game->get_counter(counter)>=amount)
20414 goto switched;
20415
20416 (void)grab_next_argument();
20417 return true;
20418 }
20419
20420 case MSGC_GOTOIFTRICOUNT:
20421 {
20422 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20423 goto switched;
20424
20425 (void)grab_next_argument();
20426 return true;
20427 }
20428
20429 case MSGC_GOTOIFTRI:
20430 {
20431 int32_t lev = (int32_t)(grab_next_argument());
20432
20433 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20434 goto switched;
20435
20436 (void)grab_next_argument();
20437 return true;
20438 }
20439
20440 case MSGC_SETUPMENU:
20441 {
20442 2 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20443 2 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20444 2 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20445 2 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20446 2 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20447 2 return true;
20448 }
20449
20450 case MSGC_MENUCHOICE:
20451 {
20452 8 int32_t pos = grab_next_argument();
20453 8 int32_t upos = grab_next_argument();
20454 8 int32_t dpos = grab_next_argument();
20455 8 int32_t lpos = grab_next_argument();
20456 8 int32_t rpos = grab_next_argument();
20457
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20458 {
20459 2 ssc_tile_hei = ssc_tile_hei_buf;
20460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20461 2 ssc_tile_hei_buf = -1;
20462 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20464 2 cursor_x=msg_margins[left];
20465 2 }
20466
20467 16 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20468 8 upos, dpos, lpos, rpos);
20469
20470
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20471 8 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20472 8 return true;
20473 }
20474
20475 case MSGC_RUNMENU:
20476 {
20477 2 msg_menu_data[MNU_CHOSEN] = 0;
20478 2 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(menu_options.size() < 1)
20480 return true;
20481 2 do_run_menu = true;
20482 2 return true;
20483 }
20484
20485 case MSGC_GOTOMENUCHOICE:
20486 {
20487 4 int32_t choice = grab_next_argument();
20488
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(msg_menu_data[MNU_CHOSEN] == choice)
20489 2 goto switched;
20490 2 (void)grab_next_argument();
20491 2 return true;
20492 }
20493
20494 case MSGC_ENDSTRING:
20495 {
20496 1 do_end_str = true;
20497 1 return true;
20498 }
20499 case MSGC_WAIT_ADVANCE:
20500 {
20501 wait_advance = true;
20502 linkedmsgclk = 51;
20503 return true;
20504 }
20505 case MSGC_TRIGSECRETS:
20506 {
20507 bool perm = (bool)grab_next_argument();
20508 hidden_entrance(0, true, false, -8);
20509 if(perm)
20510 setmapflag(mSECRET);
20511 return true;
20512 }
20513 case MSGC_TRIG_CMB_COPYCAT:
20514 {
20515 int copy_id = (int)grab_next_argument();
20516 if(copy_id == byte(copy_id))
20517 trig_copycat(copy_id);
20518 return true;
20519 }
20520 case MSGC_SETSCREENSTATE:
20521 {
20522 int32_t flag = int32_t(grab_next_argument());
20523 if(unsigned(flag)>=mMAXIND)
20524 {
20525 Z_error("SCC 133: Flag %d is invalid\n", flag);
20526 return true;
20527 }
20528 bool state = bool(grab_next_argument());
20529 if(state)
20530 setmapflag(1<<flag);
20531 else
20532 unsetmapflag(1<<flag,true);
20533 return true;
20534 }
20535 case MSGC_SETSCREENSTATER:
20536 {
20537 int32_t map = (int32_t)grab_next_argument();
20538 int32_t scrid = (int32_t)grab_next_argument();
20539 if(map < 1 || map > map_count)
20540 {
20541 Z_error("SCC 134: Map %d is invalid\n", map);
20542 return true;
20543 }
20544 if(unsigned(scrid)>=0x80)
20545 {
20546 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20547 return true;
20548 }
20549
20550 int32_t flag = int32_t(grab_next_argument());
20551 if(unsigned(flag)>=mMAXIND)
20552 {
20553 Z_error("SCC 134: Flag %d is invalid\n", flag);
20554 return true;
20555 }
20556 bool state = bool(grab_next_argument());
20557 if(state)
20558 setmapflag(mapind(map,scrid),1<<flag);
20559 else
20560 unsetmapflag(mapind(map,scrid),1<<flag,true);
20561 return true;
20562 }
20563 switched:
20564 44 int32_t lev = (int32_t)(grab_next_argument());
20565
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
44 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20566
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 31 times.
44 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20567 {
20568 msgstr=lev;
20569 msgpos=msgptr=0;
20570 msgfont=setmsgfont();
20571 }
20572 else
20573 {
20574 44 donewmsg(lev);
20575 44 ssc_tile_hei_buf = -1;
20576 }
20577 44 msgptr--; // To counteract it being incremented after this routine is called.
20578 44 putprices(false);
20579 44 return true;
20580 }
20581
20582 237259 return false;
20583 242981 }
20584
20585 // Wraps the message string... probably.
20586 233741 void wrapmsgstr(char *s3)
20587 {
20588 233741 int32_t j=0;
20589
20590
2/2
✓ Branch 0 taken 23941 times.
✓ Branch 1 taken 209800 times.
233741 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20591 {
20592
2/2
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 19174 times.
23941 if(msgspace)
20593 {
20594 4767 char c = MsgStrings[msgstr].s[msgptr];
20595
4/6
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4440 times.
✗ Branch 5 not taken.
4767 if(c != ' ' && c >= 32 && c <= 126)
20596 {
20597
4/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 24450 times.
✓ Branch 2 taken 20132 times.
✓ Branch 3 taken 4440 times.
24572 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
20598 {
20599
3/4
✓ Branch 0 taken 19569 times.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19569 times.
20132 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
20600 20132 }
20601
20602 4440 s3[j] = 0;
20603 4440 msgspace = false;
20604 4440 }
20605 else
20606 {
20607 327 s3[0] = c;
20608 327 s3[1] = 0;
20609 }
20610 4767 }
20611 else
20612 {
20613 19174 s3[0] = MsgStrings[msgstr].s[msgptr];
20614 19174 s3[1] = 0;
20615
20616
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4045 times.
19174 if(s3[0] == ' ') msgspace=true;
20617 }
20618 23941 }
20619 else
20620 {
20621 209800 s3[0] = MsgStrings[msgstr].s[msgptr];
20622 209800 s3[1] = 0;
20623 }
20624 233741 }
20625
20626 // Returns true if the pointer is at a string's
20627 // null terminator or a trailing space
20628 805686 bool atend(char const* str)
20629 {
20630 805686 int32_t i=0;
20631
20632
2/2
✓ Branch 0 taken 6343123 times.
✓ Branch 1 taken 805686 times.
7148809 while(str[i]==' ')
20633 6343123 i++;
20634
20635 805686 return str[i]=='\0';
20636 }
20637
20638 14467299 void putmsg()
20639 {
20640 14467299 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
20641
2/2
✓ Branch 0 taken 668908 times.
✓ Branch 1 taken 13798391 times.
14467299 if(!msgorig) msgorig=msgstr;
20642
20643
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14467299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14467299 if(wait_advance && linkedmsgclk < 1)
20644 linkedmsgclk = 1;
20645
2/2
✓ Branch 0 taken 14194616 times.
✓ Branch 1 taken 272683 times.
14467299 if(linkedmsgclk>0)
20646 {
20647
2/2
✓ Branch 0 taken 126232 times.
✓ Branch 1 taken 146451 times.
272683 if(linkedmsgclk==1)
20648 {
20649
6/6
✓ Branch 0 taken 126231 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 123411 times.
✓ Branch 3 taken 2820 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 123303 times.
126232 if(do_end_str||cAbtn()||cBbtn())
20650 {
20651 2929 do_end_str = false;
20652 2929 linkedmsgclk = 0;
20653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2929 times.
2929 if(wait_advance)
20654 {
20655 wait_advance = false;
20656 }
20657 else
20658 {
20659 2929 msgstr=MsgStrings[msgstr].nextstring;
20660 2929 ssc_tile_hei_buf = -1;
20661
3/4
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 1986 times.
✓ Branch 2 taken 943 times.
✗ Branch 3 not taken.
2929 if(!msgstr && enqueued_str)
20662 {
20663 msgstr = enqueued_str;
20664 enqueued_str = 0;
20665 }
20666
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 943 times.
2929 if(!msgstr)
20667 {
20668 943 msgfont=get_zc_font(font_zfont);
20669
20670
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 939 times.
943 if(tmpscr->room!=rGRUMBLE)
20671 939 blockpath=false;
20672
20673 943 dismissmsg();
20674 943 goto disappear;
20675 }
20676
20677 1986 donewmsg(msgstr);
20678 1986 putprices(false);
20679 }
20680 1986 }
20681 125289 }
20682 else
20683 {
20684 146451 --linkedmsgclk;
20685 }
20686 271740 }
20687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14466356 times.
14466356 if(wait_advance) return; //Waiting for buttonpress
20688
20689
10/10
✓ Branch 0 taken 14464043 times.
✓ Branch 1 taken 2313 times.
✓ Branch 2 taken 663737 times.
✓ Branch 3 taken 13800306 times.
✓ Branch 4 taken 527084 times.
✓ Branch 5 taken 136653 times.
✓ Branch 6 taken 263640 times.
✓ Branch 7 taken 263444 times.
✓ Branch 8 taken 854 times.
✓ Branch 9 taken 262786 times.
14466356 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
20690 {
20691
2/2
✓ Branch 0 taken 400951 times.
✓ Branch 1 taken 13800306 times.
14201257 if(!msgstr)
20692 13800306 msgorig=0;
20693
20694 14201257 msg_active = false;
20695 14201257 return;
20696 }
20697
20698 265099 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20699
20700 char s3[145];
20701 int32_t tlength;
20702
20703 // Bypass the string with the B button!
20704
4/4
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 263756 times.
✓ Branch 2 taken 1240 times.
✓ Branch 3 taken 262516 times.
265099 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
20705 {
20706 //finish writing out the string
20707
4/4
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 79061 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 77932 times.
80514 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
20708 {
20709
5/6
✓ Branch 0 taken 18708 times.
✓ Branch 1 taken 59224 times.
✓ Branch 2 taken 18707 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 18707 times.
✗ Branch 5 not taken.
77932 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20710 1 goto breakout; // break out if message speed was changed to non-zero
20711
4/6
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77931 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 285 times.
✓ Branch 5 taken 77646 times.
77931 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20712 {
20713
1/2
✓ Branch 0 taken 77646 times.
✗ Branch 1 not taken.
77646 if(bottom_margin_clip())
20714 break;
20715
20716 77646 wrapmsgstr(s3);
20717
20718
2/2
✓ Branch 0 taken 20449 times.
✓ Branch 1 taken 57197 times.
77646 if(MsgStrings[msgstr].s[msgptr]==' ')
20719 {
20720 20449 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20721
20722
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1347 times.
21843 if(cursor_x+tlength > (msg_w-msg_margins[right])
20723
5/6
✓ Branch 0 taken 1394 times.
✓ Branch 1 taken 19055 times.
✓ Branch 2 taken 1394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1300 times.
✓ Branch 5 taken 47 times.
20449 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20724 47 ? true : strcmp(s3," ")!=0))
20725 {
20726 1347 ssc_tile_hei = ssc_tile_hei_buf;
20727
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20728 1347 ssc_tile_hei_buf = -1;
20729 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
20730
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
20731 1347 cursor_x=msg_margins[left];
20732 1347 }
20733
20734 20449 char buf[2] = {0};
20735 20449 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20736
20737 20449 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20738
20739 20449 cursor_x+=tlength;
20740 20449 }
20741 else
20742 {
20743 57197 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20744
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 536 times.
57923 if(cursor_x+tlength > (msg_w-msg_margins[right])
20745
5/6
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 56424 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 583 times.
✗ Branch 5 not taken.
57197 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20746 190 ? true : strcmp(s3," ")!=0))
20747 {
20748 773 ssc_tile_hei = ssc_tile_hei_buf;
20749
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20750 773 ssc_tile_hei_buf = -1;
20751 773 cursor_y += thei + MsgStrings[msgstr].vspace;
20752
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(bottom_margin_clip()) break;
20753 773 cursor_x=msg_margins[left];
20754 773 }
20755
20756 57197 sfx(MsgStrings[msgstr].sfx);
20757
20758 57197 char buf[2] = {0};
20759 57197 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20760
20761 57197 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20762
20763 57197 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20764 57197 cursor_x += MsgStrings[msgstr].hspace;
20765 }
20766
20767 77646 msgpos++;
20768 77646 }
20769
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_run_menu)
20770 {
20771 if(runMenuCursor())
20772 {
20773 do_run_menu = false;
20774 }
20775 else break;
20776 }
20777
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(doing_name_insert)
20778 {
20779 if(*nameptr)
20780 {
20781 if(bottom_margin_clip())
20782 break;
20783
20784 char s3[9] = {0};
20785
20786 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20787 {
20788 strcpy(s3, nameptr);
20789 }
20790 else
20791 {
20792 s3[0] = *nameptr;
20793 s3[1] = 0;
20794 }
20795
20796 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20797
20798 if(cursor_x+tlength > (msg_w-msg_margins[right])
20799 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20800 ? true : strcmp(s3," ")!=0))
20801 {
20802 ssc_tile_hei = ssc_tile_hei_buf;
20803 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20804 ssc_tile_hei_buf = -1;
20805 cursor_y += thei + MsgStrings[msgstr].vspace;
20806 if(bottom_margin_clip()) break;
20807 cursor_x=msg_margins[left];
20808 }
20809
20810 sfx(MsgStrings[msgstr].sfx);
20811
20812 char buf[2] = {0};
20813 sprintf(buf,"%c",*nameptr);
20814
20815 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20816
20817 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
20818 cursor_x += MsgStrings[msgstr].hspace;
20819 ++nameptr;
20820 continue; //don't advance the msgptr, as the next char in it was not processed!
20821 }
20822 else doing_name_insert = false;
20823 }
20824 77931 ++msgptr;
20825
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_end_str)
20826 goto strendcheck;
20827
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(wait_advance)
20828 return;
20829
2/2
✓ Branch 0 taken 76718 times.
✓ Branch 1 taken 1213 times.
77931 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20830 {
20831
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 786 times.
1213 if(MsgStrings[msgstr].nextstring)
20832 {
20833
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20834 {
20835 msgstr=MsgStrings[msgstr].nextstring;
20836 msgpos=msgptr=0;
20837 msgfont=setmsgfont();
20838 }
20839 786 }
20840 1213 }
20841 }
20842
20843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if (!do_run_menu)
20844 {
20845 1232 msgclk = 72;
20846 1232 msgpos = 10000;
20847 1232 }
20848 1232 }
20849 else
20850 262516 {
20851 breakout:
20852 262517 word tempspeed = msgspeed;
20853
2/2
✓ Branch 0 taken 261554 times.
✓ Branch 1 taken 963 times.
262517 if (do_run_menu)
20854 963 tempspeed = 0;
20855
6/6
✓ Branch 0 taken 210795 times.
✓ Branch 1 taken 51722 times.
✓ Branch 2 taken 120294 times.
✓ Branch 3 taken 90501 times.
✓ Branch 4 taken 113455 times.
✓ Branch 5 taken 6839 times.
262517 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20856 97340 return;
20857 }
20858
20859 // Start writing the string
20860
2/2
✓ Branch 0 taken 163526 times.
✓ Branch 1 taken 2883 times.
169292 if(msgptr == 0)
20861 {
20862
2/2
✓ Branch 0 taken 2883 times.
✓ Branch 1 taken 5068 times.
7951 while(MsgStrings[msgstr].s[msgptr]==' ')
20863 {
20864 5068 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20865
20866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
5156 if(cursor_x+tlength > (msg_w-msg_margins[right])
20867
4/6
✓ Branch 0 taken 4980 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
5068 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20868 ? 1 : strcmp(s3," ")!=0))
20869 {
20870 88 ssc_tile_hei = ssc_tile_hei_buf;
20871
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20872 88 ssc_tile_hei_buf = -1;
20873 88 cursor_y += thei + MsgStrings[msgstr].vspace;
20874
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(bottom_margin_clip()) break;
20875 88 cursor_x=msg_margins[left];
20876 88 }
20877
20878 5068 cursor_x+=tlength;
20879 5068 ++msgptr;
20880 5068 ++msgpos;
20881
20882 // The "Continue From Previous" feature
20883
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1368 times.
5068 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20884 {
20885
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
20886 {
20887 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20888 {
20889 msgstr=MsgStrings[msgstr].nextstring;
20890 msgpos=msgptr=0;
20891 msgfont=setmsgfont();
20892 }
20893 }
20894 1368 }
20895 }
20896 2883 }
20897
20898 reparsesinglechar:
20899 // Continue printing the string!
20900
3/4
✓ Branch 0 taken 159832 times.
✓ Branch 1 taken 6579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 159832 times.
326240 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
20901 {
20902
6/6
✓ Branch 0 taken 158869 times.
✓ Branch 1 taken 963 times.
✓ Branch 2 taken 158845 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2750 times.
✓ Branch 5 taken 156095 times.
159832 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20903 {
20904 156095 wrapmsgstr(s3);
20905
20906 156095 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20907
20908
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1867 times.
158218 if(cursor_x+tlength > (msg_w-msg_margins[right])
20909
6/6
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 153929 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 1867 times.
✓ Branch 5 taken 43 times.
156095 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20910 256 ? true : strcmp(s3," ")!=0))
20911 {
20912 2123 ssc_tile_hei = ssc_tile_hei_buf;
20913
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20914 2123 ssc_tile_hei_buf = -1;
20915 2123 cursor_y += thei + MsgStrings[msgstr].vspace;
20916
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(bottom_margin_clip()) goto strendcheck;
20917 2123 cursor_x=msg_margins[left];
20918 //if(space) s3[0]=0;
20919 2123 }
20920
20921 156095 sfx(MsgStrings[msgstr].sfx);
20922
20923 156095 char buf[2] = {0};
20924 156095 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20925
20926 156095 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20927
20928 156095 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20929 156095 cursor_x += MsgStrings[msgstr].hspace;
20930 156095 msgpos++;
20931 156095 }
20932
2/2
✓ Branch 0 taken 159831 times.
✓ Branch 1 taken 1 times.
159832 if(do_end_str)
20933 1 goto strendcheck;
20934
1/2
✓ Branch 0 taken 159831 times.
✗ Branch 1 not taken.
159831 if(wait_advance)
20935 {
20936 ++msgptr;
20937 return;
20938 }
20939
2/2
✓ Branch 0 taken 965 times.
✓ Branch 1 taken 158866 times.
159831 else if(do_run_menu)
20940 {
20941
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 963 times.
965 if(runMenuCursor())
20942 {
20943 2 do_run_menu = false;
20944 2 ++msgptr;
20945 2 goto reparsesinglechar;
20946 }
20947 963 }
20948
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 158836 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
158866 else if(doing_name_insert && *nameptr)
20949 {
20950 24 char s3[9] = {0};
20951
20952
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20953 {
20954 24 strcpy(s3, nameptr);
20955 24 }
20956 else
20957 {
20958 s3[0] = *nameptr;
20959 s3[1] = 0;
20960 }
20961
20962 24 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20963
20964
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if(cursor_x+tlength > (msg_w-msg_margins[right])
20965
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20966 ? true : strcmp(s3," ")!=0))
20967 {
20968 ssc_tile_hei = ssc_tile_hei_buf;
20969 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20970 ssc_tile_hei_buf = -1;
20971 cursor_y += thei + MsgStrings[msgstr].vspace;
20972 if(bottom_margin_clip()) goto strendcheck;
20973 cursor_x=msg_margins[left];
20974 }
20975
20976 24 sfx(MsgStrings[msgstr].sfx);
20977
20978 24 char buf[2] = {0};
20979 24 sprintf(buf,"%c",*nameptr);
20980
20981 24 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20982
20983 24 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
20984 24 cursor_x += MsgStrings[msgstr].hspace;
20985 24 ++nameptr;
20986 24 }
20987 else
20988 {
20989 158842 doing_name_insert = false;
20990 158842 msgptr++;
20991
20992
2/2
✓ Branch 0 taken 156149 times.
✓ Branch 1 taken 2693 times.
158842 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20993 {
20994
2/2
✓ Branch 0 taken 1492 times.
✓ Branch 1 taken 1201 times.
2693 if(MsgStrings[msgstr].nextstring)
20995 {
20996
1/2
✓ Branch 0 taken 1201 times.
✗ Branch 1 not taken.
1201 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20997 {
20998 msgstr=MsgStrings[msgstr].nextstring;
20999 msgpos=msgptr=0;
21000 msgfont=setmsgfont();
21001 }
21002 1201 }
21003 2693 }
21004
21005
2/2
✓ Branch 0 taken 23711 times.
✓ Branch 1 taken 4519 times.
187072 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21006
2/2
✓ Branch 0 taken 158321 times.
✓ Branch 1 taken 521 times.
158842 && (MsgStrings[msgstr].s[msgptr]==' ')
21007
2/2
✓ Branch 0 taken 28230 times.
✓ Branch 1 taken 130091 times.
158321 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21008 {
21009
2/2
✓ Branch 0 taken 4513 times.
✓ Branch 1 taken 156761 times.
161274 while(MsgStrings[msgstr].s[msgptr]==' ')
21010 {
21011 156761 msgspace = true;
21012 156761 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21013
21014
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6280 times.
163505 if(cursor_x+tlength > (msg_w-msg_margins[right])
21015
4/6
✓ Branch 0 taken 6744 times.
✓ Branch 1 taken 150017 times.
✓ Branch 2 taken 6744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6280 times.
✗ Branch 5 not taken.
156761 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21016 464 ? true : strcmp(s3," ")!=0))
21017 {
21018 6744 ssc_tile_hei = ssc_tile_hei_buf;
21019
1/2
✓ Branch 0 taken 6744 times.
✗ Branch 1 not taken.
6744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21020 6744 ssc_tile_hei_buf = -1;
21021 6744 cursor_y += thei + MsgStrings[msgstr].vspace;
21022
2/2
✓ Branch 0 taken 6738 times.
✓ Branch 1 taken 6 times.
6744 if(bottom_margin_clip()) break;
21023 6738 cursor_x=msg_margins[left];
21024 6738 }
21025
21026 156755 cursor_x+=tlength;
21027 156755 ++msgpos;
21028 156755 ++msgptr;
21029
21030
2/2
✓ Branch 0 taken 10215 times.
✓ Branch 1 taken 146540 times.
156755 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21031 {
21032
2/2
✓ Branch 0 taken 87448 times.
✓ Branch 1 taken 59092 times.
146540 if(MsgStrings[msgstr].nextstring)
21033 {
21034
1/2
✓ Branch 0 taken 59092 times.
✗ Branch 1 not taken.
59092 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21035 {
21036 msgstr=MsgStrings[msgstr].nextstring;
21037 msgpos=msgptr=0;
21038 msgfont=setmsgfont();
21039 }
21040 59092 }
21041 146540 }
21042 }
21043 4519 }
21044 }
21045 159829 }
21046 strendcheck:
21047 // Done printing the string
21048
14/14
✓ Branch 0 taken 166408 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 166384 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 165421 times.
✓ Branch 5 taken 963 times.
✓ Branch 6 taken 164189 times.
✓ Branch 7 taken 1232 times.
✓ Branch 8 taken 161624 times.
✓ Branch 9 taken 2565 times.
✓ Branch 10 taken 161618 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 159216 times.
✓ Branch 13 taken 6205 times.
166409 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21049 {
21050
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6205 times.
6206 if(!do_end_str)
21051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6205 times.
6205 while(parsemsgcode()); // Finish remaining control codes
21052
21053 // Go to next string, or make it disappear by going to string 0.
21054
5/6
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
✓ Branch 2 taken 3275 times.
✓ Branch 3 taken 944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
6206 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21055 {
21056 2931 linkedmsgclk=do_end_str?1:51;
21057 2931 }
21058
21059
2/2
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
6206 if(MsgStrings[msgstr].nextstring==0)
21060 {
21061
2/2
✓ Branch 0 taken 944 times.
✓ Branch 1 taken 3275 times.
4219 if(!get_qr(qr_MSGDISAPPEAR))
21062 3275 {
21063 disappear:
21064 4218 msg_active = false;
21065 4218 Hero.finishedmsg();
21066 4218 }
21067
21068
2/2
✓ Branch 0 taken 5149 times.
✓ Branch 1 taken 13 times.
5162 if(repaircharge)
21069 {
21070 // if (get_qr(qr_REPAIRFIX)) {
21071 // fixed_door=true;
21072 // }
21073 13 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21074 13 repaircharge = 0;
21075 13 }
21076
21077
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(adjustmagic)
21078 {
21079
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
21080 {
21081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(game->get_magicdrainrate())
21082 2 game->set_magicdrainrate(1);
21083 2 }
21084 else if(game->get_magicdrainrate() > 1)
21085 {
21086 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21087 }
21088 2 adjustmagic = false;
21089 2 sfx(WAV_SCALE);
21090
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21091 2 }
21092
21093
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(learnslash)
21094 {
21095 2 game->set_canslash(1);
21096 2 learnslash = false;
21097 2 sfx(WAV_SCALE);
21098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21099 2 }
21100 5162 }
21101 7149 }
21102 14465949 }
21103
21104 124237 int32_t message_more_y()
21105 {
21106 //Is the flag ticked, do we really want a message more y larger than 160?
21107
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124209 times.
✓ Branch 2 taken 124237 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124209 times.
✓ Branch 5 taken 28 times.
124237 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21108 124237 msgy+=playing_field_offset;
21109 124237 return msgy;
21110 }
21111
21112 /*** Collision detection & handling ***/
21113
21114 14167539 void clear_script_one_frame_conditions()
21115 {
21116
2/2
✓ Branch 0 taken 38764554 times.
✓ Branch 1 taken 14167539 times.
52932093 for(int32_t j=0; j<guys.Count(); j++)
21117 {
21118 38764554 enemy *e = (enemy*)guys.spr(j);
21119
2/2
✓ Branch 0 taken 658997418 times.
✓ Branch 1 taken 38764554 times.
697761972 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21120 38764554 }
21121 14167539 }
21122
21123 4851789 void check_enemy_lweapon_collision(weapon *w)
21124 {
21125
8/8
✓ Branch 0 taken 4239709 times.
✓ Branch 1 taken 612080 times.
✓ Branch 2 taken 3250738 times.
✓ Branch 3 taken 988971 times.
✓ Branch 4 taken 3188654 times.
✓ Branch 5 taken 62084 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3171916 times.
4851789 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21126 {
21127
2/2
✓ Branch 0 taken 3156345 times.
✓ Branch 1 taken 11156732 times.
14313077 for(int32_t j=0; j<guys.Count(); j++)
21128 {
21129 11156732 enemy *e = (enemy*)guys.spr(j);
21130
21131 11156732 bool didhit = e->hit(w);
21132
2/2
✓ Branch 0 taken 10936278 times.
✓ Branch 1 taken 220454 times.
11156732 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21133 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21134 {
21135 // !(e->stunclk)
21136 220454 int32_t h = e->takehit(w);
21137
2/2
✓ Branch 0 taken 187020 times.
✓ Branch 1 taken 33434 times.
220454 if (h == -1)
21138 {
21139 33434 int indx = Lwpns.find(w);
21140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33434 times.
33434 if(indx > -1)
21141 33434 e->hitby[HIT_BY_LWEAPON] = indx+1;
21142 33434 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21143 33434 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21144
2/2
✓ Branch 0 taken 31264 times.
✓ Branch 1 taken 2170 times.
33434 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21145 2170 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21146 33434 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21147 33434 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21148
21149 33434 }
21150 //we may need to handle this in special cases. -Z
21151
21152 //if h == stun or ignore
21153
21154 //if e->stun > DEFAULT_STUN -1 || !e->stun
21155 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21156 ///! how about: if w->dead != bounce !
21157
21158 // NOT FOR PUBLIC RELEASE
21159 /*if(h==3) //Mirror shield
21160 {
21161 if (w->id==ewFireball || w->id==wRefFireball)
21162 {
21163 w->id=wRefFireball;
21164 switch(e->dir)
21165 {
21166 case up: e->angle += (PI - e->angle) * 2.0; break;
21167 case down: e->angle = -e->angle; break;
21168 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21169 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21170 // TODO: the following. -L.
21171 case l_up: break;
21172 case r_up: break;
21173 case l_down: break;
21174 case r_down: break;
21175 }
21176 }
21177 else
21178 {
21179 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21180 w->dir ^= 1;
21181 if(w->dir&2)
21182 w->flip ^= 1;
21183 else
21184 w->flip ^= 2;
21185 }
21186 w->ignoreHero=false;
21187 }
21188 else*/
21189
2/2
✓ Branch 0 taken 176421 times.
✓ Branch 1 taken 44033 times.
220454 if(h)
21190 {
21191
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44029 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44033 if(e->switch_hooked && w->family_class == itype_switchhook)
21192 w->onhit(false, e, -1);
21193 44033 else w->onhit(false, e, h);
21194 44033 }
21195
21196
2/2
✓ Branch 0 taken 217780 times.
✓ Branch 1 taken 2674 times.
220454 if(h==2)
21197 {
21198 2674 break;
21199 }
21200 217780 }
21201
21202
2/2
✓ Branch 0 taken 11141161 times.
✓ Branch 1 taken 12897 times.
11154058 if(w->Dead())
21203 {
21204 12897 break;
21205 }
21206 11141161 }
21207
21208 // Item flags added in 2.55:
21209 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
21210 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21211 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21212 // -Em
21213
6/6
✓ Branch 0 taken 2717941 times.
✓ Branch 1 taken 453975 times.
✓ Branch 2 taken 2673369 times.
✓ Branch 3 taken 44572 times.
✓ Branch 4 taken 43559 times.
✓ Branch 5 taken 2629810 times.
3171916 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21214 {
21215 542106 int32_t itype, pitem = w->parentitem;
21216
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453975 times.
✓ Branch 2 taken 43559 times.
✓ Branch 3 taken 44572 times.
542106 switch(w->id)
21217 {
21218 453975 case wBrang: itype = itype_brang; break;
21219 43559 case wArrow: itype = itype_arrow; break;
21220 case wHookshot:
21221 44572 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21222 44572 break;
21223 }
21224
2/2
✓ Branch 0 taken 537254 times.
✓ Branch 1 taken 4852 times.
542106 if(pitem < 0) pitem = current_item_id(itype);
21225
5/6
✓ Branch 0 taken 44572 times.
✓ Branch 1 taken 497534 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44472 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
542106 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
21226 { //Swap with item
21227 for(int32_t j=0; j<items.Count(); j++)
21228 {
21229 if(items.spr(j)->hit(w))
21230 {
21231 item *theItem = ((item*)items.spr(j));
21232 bool priced = theItem->PriceIndex >-1;
21233 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21234 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21235 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21236 {
21237 if(!Hero.switchhookclk)
21238 {
21239 hooked_combopos = -1;
21240 hooked_layerbits = 0;
21241 switching_object = theItem;
21242 theItem->switch_hooked = true;
21243 w->misc = 2;
21244 w->step = 0;
21245 theItem->clk2=256;
21246 Hero.doSwitchHook(game->get_switchhookstyle());
21247 if(QMisc.miscsfx[sfxSWITCHED])
21248 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21249 }
21250 }
21251 }
21252 }
21253 }
21254
6/6
✓ Branch 0 taken 43559 times.
✓ Branch 1 taken 498547 times.
✓ Branch 2 taken 374087 times.
✓ Branch 3 taken 330528 times.
✓ Branch 4 taken 498547 times.
✓ Branch 5 taken 330528 times.
542106 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21255 {
21256
2/2
✓ Branch 0 taken 87310 times.
✓ Branch 1 taken 374087 times.
461397 for(int32_t j=0; j<items.Count(); j++)
21257 {
21258
2/2
✓ Branch 0 taken 82412 times.
✓ Branch 1 taken 4898 times.
87310 if(items.spr(j)->hit(w))
21259 {
21260 4898 item *theItem = ((item*)items.spr(j));
21261 4898 bool priced = theItem->PriceIndex >-1;
21262
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21263
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21264
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21265 {
21266
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21267 {
21268 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21269 }
21270
21271 1724 Hero.checkitems(j);
21272 1724 }
21273 4898 }
21274 87310 }
21275 374087 }
21276
2/2
✓ Branch 0 taken 14738 times.
✓ Branch 1 taken 153281 times.
829075 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21277 {
21278
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21279 {
21280
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21281 {
21282 8688 item *theItem = ((item*)items.spr(j));
21283 8688 bool priced = theItem->PriceIndex >-1;
21284
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21285
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21286
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21287 {
21288 7273 int32_t pickup = theItem->pickup;
21289 7273 int32_t id2 = theItem->id;
21290 7273 int32_t pstr = theItem->pstring;
21291 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21292
21293 7273 std::vector<int32_t> &ev = FFCore.eventData;
21294 7273 ev.clear();
21295 7273 ev.push_back(id2*10000);
21296 7273 ev.push_back(pickup*10000);
21297 7273 ev.push_back(pstr*10000);
21298 7273 ev.push_back(pstr_flags*10000);
21299 7273 ev.push_back(0);
21300 7273 ev.push_back(theItem->getUID());
21301 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21302 7273 ev.push_back(w->getUID());
21303
21304 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21305 7273 bool nullify = ev[4] != 0;
21306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21307
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21308 {
21309 6197 w->onhit(false);
21310 6197 }
21311
21312
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21313 {
21314 498 w->dead=1;
21315 498 theItem->clk2=256;
21316 498 w->dragging=j;
21317 498 theItem->is_dragged = true;
21318 498 }
21319 7273 }
21320 8688 }
21321 36900 }
21322 153281 }
21323 542106 }
21324 3171916 }
21325 4851789 }
21326 14165383 void check_collisions()
21327 {
21328
2/2
✓ Branch 0 taken 4851749 times.
✓ Branch 1 taken 14165383 times.
19017132 for(uint q = 0; q < Lwpns.Count(); ++q)
21329 4851749 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21330 14165383 }
21331
21332 14167539 void dragging_item()
21333 {
21334
2/2
✓ Branch 0 taken 4967058 times.
✓ Branch 1 taken 14167539 times.
19134597 for(int32_t i=0; i<Lwpns.Count(); i++)
21335 {
21336 4967058 weapon *w = (weapon*)Lwpns.spr(i);
21337
21338
4/4
✓ Branch 0 taken 4504494 times.
✓ Branch 1 taken 462564 times.
✓ Branch 2 taken 4811799 times.
✓ Branch 3 taken 155259 times.
4967058 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21339 {
21340
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21341 {
21342 7247 item* dragItem = (item*)items.spr(w->dragging);
21343 7247 dragItem->x=w->x;
21344 7247 dragItem->y=w->y;
21345
21346 // Drag the Fairy enemy as well as the Fairy item
21347 7247 int32_t id = dragItem->id;
21348
21349
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21350 {
21351 404 movefairynew2(w->x,w->y,*dragItem);
21352 404 }
21353 7247 }
21354 155259 }
21355 4967058 }
21356 14167539 }
21357
21358 55 int32_t more_carried_items()
21359 {
21360 55 int32_t hasmorecarries = 0;
21361
21362
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 55 times.
115 for(int32_t i=0; i<items.Count(); i++)
21363 {
21364
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 55 times.
60 if(((item*)items.spr(i))->pickup & ipENEMY)
21365 {
21366 55 hasmorecarries++;
21367 55 }
21368 60 }
21369
21370 55 return hasmorecarries;
21371 }
21372
21373 // messy code to do the enemy-carrying-the-item thing
21374 14167539 void roaming_item()
21375 {
21376
4/4
✓ Branch 0 taken 28207 times.
✓ Branch 1 taken 14139332 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 28137 times.
14167539 if(!(hasitem&(4|2)) || !loaded_enemies)
21377 14139402 return;
21378
21379 // All enemies already dead upon entering a room?
21380
1/2
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
28137 if(guys.Count()==0)
21381 {
21382 return;
21383 }
21384
21385 // Lost track of the carrier?
21386
5/6
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28131 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 28115 times.
✓ Branch 5 taken 16 times.
28137 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21387 28131 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21388 {
21389 22 guycarryingitem=-1;
21390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 for(int32_t j=0; j<guys.Count(); j++)
21391 {
21392
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 22 times.
84 if(((enemy*)guys.spr(j))->itemguy)
21393 {
21394 22 guycarryingitem=j;
21395 22 break;
21396 }
21397 62 }
21398 22 }
21399
21400
2/2
✓ Branch 0 taken 28073 times.
✓ Branch 1 taken 64 times.
28137 if(hasitem&4)
21401 {
21402 64 guycarryingitem = -1;
21403
21404
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 64 times.
477 for(int32_t i=0; i<guys.Count(); i++)
21405 {
21406
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 64 times.
413 if(((enemy*)guys.spr(i))->itemguy)
21407 {
21408 64 guycarryingitem = i;
21409 64 }
21410 413 }
21411
21412
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(guycarryingitem == -1) //This happens when "default enemies" such as
21413 {
21414 return; //eSHOOTFBALL are alive but enemies from the list
21415 } //are not. Defer to HeroClass::checkspecial().
21416
21417 64 int32_t Item=tmpscr->item;
21418
21419 64 hasitem &= ~4;
21420
21421
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21422 {
21423 115 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21424
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 13 times.
64 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21425 );
21426 64 hasitem |= 2;
21427 64 }
21428 else
21429 {
21430 return;
21431 }
21432 64 }
21433
21434
2/2
✓ Branch 0 taken 29483 times.
✓ Branch 1 taken 28137 times.
57620 for(int32_t i=0; i<items.Count(); i++)
21435 {
21436
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 28137 times.
29483 if(((item*)items.spr(i))->pickup&ipENEMY)
21437 {
21438
2/2
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 13865 times.
28137 if(get_qr(qr_HIDECARRIEDITEMS))
21439 {
21440 14272 items.spr(i)->x = -128; // Awfully inelegant, innit?
21441 14272 items.spr(i)->y = -128;
21442 14272 }
21443
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21444 {
21445
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21446 {
21447 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21448 {
21449 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21450 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21451 }
21452 else
21453 {
21454 if(guys.spr(guycarryingitem)->extend >= 3)
21455 {
21456 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21457 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21458 }
21459 else
21460 {
21461 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21462 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21463 }
21464 }
21465 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21466 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21467 }
21468 else
21469 {
21470 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21471 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21472 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21473 }
21474 13865 }
21475 28137 }
21476 29483 }
21477 14167539 }
21478
21479 bool enemy::IsBigAnim()
21480 {
21481 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21482 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21483 || anim == a4FRM8DIRB);
21484 }
21485 2389602 int32_t enemy::getFlashingCSet()
21486 {
21487 //Special cset for the dying sprite
21488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389602 times.
2389602 if(dying)
21489 {
21490 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21491 return wpnsbuf[spr_death].csets & 15;
21492 else
21493 return (((clk2 + 5) >> 1) & 3) + 6;
21494 }
21495
21496 //Normal cset
21497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389602 times.
2389602 if (hclk <= 0)
21498 {
21499 //Special cset for the flashing animation
21500 if (flags & guy_flashing)
21501 return (frame & 3) + 6;
21502 return cs;
21503 }
21504
21505 //Hurt animations
21506
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2385714 times.
2389602 if(family==eeGANON)
21507 3888 return (((hclk-1)>>1)&3)+6;
21508
4/4
✓ Branch 0 taken 2216853 times.
✓ Branch 1 taken 168861 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1729715 times.
2385714 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21509 1729715 return (((hclk-1)>>1)&3)+6;
21510
21511 655999 return cs;
21512 2389602 }
21513
21514 81522434 bool enemy::is_hitflickerframe(bool olddrawing)
21515 {
21516
6/6
✓ Branch 0 taken 81493930 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3940256 times.
✓ Branch 3 taken 77553674 times.
✓ Branch 4 taken 3167565 times.
✓ Branch 5 taken 772691 times.
81522434 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21517 80749743 return false;
21518
21519
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21520 return false;
21521
21522 772691 int32_t fr = game->get_spriteflickerspeed();
21523
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21524 return true;
21525 772691 return frame % (fr * 2) < fr;
21526 81522434 }
21527
21528 const char *old_guy_string[OLDMAXGUYS] =
21529 {
21530 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21531 // 020
21532 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21533 // 025
21534 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21535 // 030
21536 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21537 // 035
21538 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21539 // 040
21540 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21541 // 045
21542 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21543 // 050
21544 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21545 // 055
21546 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21547 // 060
21548 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21549 // 065
21550 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21551 // 070
21552 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21553 // 075
21554 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21555 // 080
21556 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21557 // 085
21558 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21559 // 090
21560 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21561 // 095
21562 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21563 // 100
21564 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21565 // 105
21566 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21567 // 110
21568 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21569 // 115
21570 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21571 // 120
21572 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21573 // 125
21574 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21575 // 130
21576 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21577 // 135
21578 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21579 // 140
21580 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21581 // 145
21582 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21583 // 150
21584 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21585 // 155
21586 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21587 // 160
21588 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21589 // 165
21590 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21591 // 170
21592 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21593 // 175
21594 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21595 };
21596